Hi there I am having a MongoDB document in users collection:
{
"_id": ObjectId("51d9534fc469880b338903eb"),
"inbox": {
"0": {},
"1": {} ,
"2": {}
...
},
}
According to requirement i need to check inbox every 5 minutes. So I am looking for:
- To find the length of inbox.
- Imagine my inbox lenght is 4 but 2 new messages came in, how would i get only those new messages.
After a bit of research i found that i can check if there are any new messages in my inbox using db.collection.find({ tags : { $size: 4 }});
, but now my question is how do i find those newly added messages. It would be really great if you can suggest a better way to get around this situation.
Thank you!