Mongoose query by date
Looking at the code I'm really not sure how it could have taken me more than one minute to figure this out.. but here's an example how to query for documents with a timestamp in the past.
Your model's schema obviously needs a timestamp field of the Date type, and it's probably a good idea to set a default value.
var now = new Date();
yourModel.find({timestamp: {$lte: now}}).exec(...);
1 comment
Reply