javascript - node js mongoose filter result according to date -
ive been stuck in situation need fetch records mongo db according date
so have start_date 2017-08-20 , end_date 2017-08-21 coming front end. have record
{ "success": 1, "total": 1, "request": 0, "response": "17", "username": "comp1", "timestamp": "2017-08-21t05:13:32.000z" } now want run mongoose query
model.find(query) from node js code data 2017-08-20 starting 00:00 2017-08-21 ending 23:59
need know query need put records of selected date, in advance
you try query this:
model.find({ timestamp: { $gte: isodate("2017-08-20t00:00:00.000z"), $lt: isodate("2017-08-21t00:00:00.000z") } }, function(err, docs) { // ... })
Comments
Post a Comment