i'm trying to query my mongoDB collection but can't get results.
this is my nodeJS code:
db.collection('events', function (err, collection) {
var now = new Date().toISOString();
var query = {endTime:{$gte:{$date: now}}};
console.log(query); // --> { endTime: { '$gte': { '$date': '2017-10-18T08:31:04.864Z' } } }
collection.find(query).toArray(function(err, items) {
console.log(items); // --> []
});
});
but if i run this query via mongoDB Compass
{ endTime: { "$gte": { "$date": "2017-10-18T08:31:04.864Z" } } }
it works! (12 results)
any help? i think i'm missing something really basic here. thanks