Reputation: 745
I am trying schema.aggregate({ $match: condition}, callback);
and in this condition object am passing
condition = { dateAttempted: {$gt :"2015-01-01T10:51:04.197Z", $lte:"2015-12-01T10:46:02.520Z}}
It is not find any record. But when i try this in mongo cmd
db.collections.aggregate({ $match: { dateAttempted: { $gte: ISODate("2015-01-01T10:51:04.197Z"), $lte: ISODate("2015-03-04T10:51:04.197Z") }}});
its working fine.
So how can i pass ISO date object from nodeJS.
Upvotes: 1
Views: 2572
Reputation: 312129
You need to convert those strings into JavaScript Date
objects:
condition = { dateAttempted: {
$gt: new Date("2015-01-01T10:51:04.197Z"),
$lte: new Date("2015-12-01T10:46:02.520Z")
}}
Upvotes: 2