Hello @all,
I have designed a collection schema to store my campaign’s visitors counts and also save its count as per visiting date to show the graphical analytics. Here is my schema design…
Schema({
userId : { type: Schema.Types.ObjectId , ref: 'users'},
title : { type: String },
slug : { type: String },
usedTemplate : { type: String },
status :{ type: boolean, default : 1},
campaignsData : { type: Object, default: {} },
visits : { type: Number, default : {}},
addedOn : { type: Date, default: Date.now },
});
and I have decided to store visits as
visits : {
totalVisits : 5,
visitDetails : {
"2022-03-01" : 1,
"2022-03-02" : 3,
"2022-03-03" : 1,
}
}
My queries are:
- Is it right schema to do same?
- If there are lots of records (assume 2 or 3 years of records it will be 365*3 records in “visits.visitDetails” keys) in my “visits” key will this effect on my query execution?