So I have a collection in which I dump logs.Each log have EndUserId field. The mongoose schema is as follows:
var mongoose = require("mongoose");
var Schema = mongoose.Schema;
var ChatbotLogsSchema = new Schema({
EndUserId: {
type: String
},
MessageType: {
type: String
},
Message:{
type: String
},
CreatedDateTime: {
type: Date, default: Date.now
},
UpdatedDateTime: {
type: Date, default: Date.now
},
SentimentScore: {
type: Number
},
EngageWeight: {
type: Number
}
}, { timestamps: { createdAt: 'CreatedDateTime',updatedAt:"UpdatedDateTime" } },{ collection: "ChatbotLogs" });
I want to get list of distinct EndUserId
which are logged in last 5 minutes and were not present in collection previously.
What will be the efficient way to achieve this?
Edit :This question is different than Query to get last X minutes data with Mongodb As I want to get only new users which were not present previously in collection.