Here is the code snippet I am using to retrieve data from a Mongo Collection:
var currentDate = moment().toISOString();
// Returns: 2016-12-10T20:36:04.494Z
var futureDate = moment().add(10, "days").toISOString();
// Returns: 2016-12-20T20:36:04.495Z
return agenda = Agendas.find({
"agendaDate": { '$gte': currentDate, '$lte': futureDate }
});
The date in the MongoDB Collection is stored as shown below:
{
"_id" : ObjectId("584877e56466dd236cd95f15"),
"agendaDate" : ISODate("2016-12-12T17:28:25.000+0000"),
"agendaTime" : "20:59",
"agendaEvent" : "Test event"
}
Despite setting up test documents, no results are being returned. There are 2 documents within the specified range, and 1 outside the range.
I need help understanding what is going wrong and correcting the code. Can anyone provide assistance?