I'm having trouble figuring out how to increment the 'totalVisits' and the 'number' of the visit matching by "Date". Trying to track my own visiting. I have lodash and moment at my disposal. Any ideas?
campaigns: {
type: [
{
_id: {
type: ObjectId,
},
totalVisits: {
type: Number,
},
visits: {
type: [
{
date: {
type: String,
},
number: {
type: Number,
},
},
],
},
etc....
So far I can update the total using this:
await Views.findOneAndUpdate(
{ "campaigns._id": "{ID}" },
{
$inc: { "campaigns.$.totalSignups": 1 },
}
);