skip to Main Content

MongoDB view with dynamic dates

I am trying to create a view for records created/modified in last 24 hours. Is it possible? Tried creating view as below db.createView( "viewname", "sourcecollection", [ { $match: {"modifiedTime":{$gte:new Date(Date.now() - 24*60*60*1000), $lte:new Date()}}}] ) But it translates to static…

VIEW QUESTION

Search mongodb data using the lt & gt comparators on the date

const queryMatch = {departureDate: {$gte: new Date(query.departureDateMin),$lte: new Date(query.departureDateMax)}}; const flightsByCriteria = await this.flightModel.find(queryMatch).exec(); The above request returns an empty table. And yet I get data with mongodbCompass using ISODate(dateString) instead of new Date(dateString) I don't know where the problem…

VIEW QUESTION
Back To Top
Search