Add createdAt
field, index it, then query
db.getCollection("COLLECTION_NAME").find({"createdAt":{$gt:new Date(Date.now() - 24*60*60 * 1000)}})
This will return all records younger than 86400 seconds.
Add createdAt
field, index it, then query
db.getCollection("COLLECTION_NAME").find({"createdAt":{$gt:new Date(Date.now() - 24*60*60 * 1000)}})
This will return all records younger than 86400 seconds.