Hi @Praduman_Tiwari ,
Well I suggest that you read our design best practices materials and antipattern.
Having an embedded object in one document with 800+ fields does not sound as a good design.
First it will create large documents which seems unnecessary. Second you won’t be able to filter on a field name …
I would suggest to use 2 collections :
campaigns collection
Schema({
userId : { type: Schema.Types.ObjectId , ref: ‘users’},
campaignId : { type: Schema.Types.ObjectId},
title : { type: String },
slug : { type: String },
usedTemplate : { type: String },
status :{ type: boolean, default : 1},
campaignsData : { type: Object, default: {} },
addedOn : { type: Date, default: Date.now },
})
visits collection
Schema({
visitDate : { type: Date },
campaignId : { type: Schema.Types.ObjectId, ref: ‘campaings’},
visits : { type: Number }
})
Now you can index campaignId : 1 , visitDate : 1 together to get different visit information for plot and analysis
Here are links to the things we talked about :
Thanks
Pavel