Open Gabrirf opened 1 year ago
I have my documents created with createdAt and updatedAt fields from mongoose feature. I normally add date filters in this way:
createdAt
updatedAt
const filters = {}; if (from) filters.createdAt = { $gte: new Date(from).toISOString() }; if (to) filters.createdAt = { $lte: new Date(to).toISOString() }; if (from && to) { filters.createdAt = { $gte: new Date(from).toISOString(), $lte: new Date(to).toISOString(), }; }
For the aggregate I use:
const options = {}; const filtersPipeline = { $match: { ...filters, }, }; const aggregateQuery = MyModel.aggregate([ filtersPipeline, ]); MyModel.aggregatePaginate(aggregateQuery, { ...options, ...paginationOptions });
It should filter from-to date, but I got an empty array on results
I'm using Node v14 with:
{ "mongoose": "5.12.9", "mongoose-aggregate-paginate-v2": "1.0.42", "mongoose-paginate-v2": "1.3.14" }
This query it's working directly on Robo3t:
db.getCollection('mymodel').aggregate([ { $match: { createdAt: { $gte: ISODate('2022-09-16T09:45:17.000Z') }, }} ])
I can't even match by _id
I have my documents created with
createdAt
andupdatedAt
fields from mongoose feature. I normally add date filters in this way:For the aggregate I use:
It should filter from-to date, but I got an empty array on results
I'm using Node v14 with:
This query it's working directly on Robo3t: