Home > Net >  How to get current time in mongo aggregate?
How to get current time in mongo aggregate?

Time:09-28

I want to get the objects that have the time property greater than current time. How to get them?

CodePudding user response:

you can try:

var date = moment().toDate()
    Model.aggregate([
{$match:{createdAt:{$gte: date}}}
])

CodePudding user response:

You can use this query if you want to query documents those have time property greater than current time

db.collection.find({"time" : { $gt : new Date() }});
  • Related