My sample document:
{
name : 'ABC123',
active: false,
meta : {
createdBy: 'user@gmail.com',
created : ISODate("2017-11-20T13:04:15.757Z"), // 13:04
editedBy : 'user2@gmail.com',
edited : ISODate("2017-11-20T13:06:06.033Z"), // 13:06
removedBy: 'user@gmail.com',
removed : ISODate("2017-11-20T13:09:11.033Z") // 13:09
}
}
How to fulfill a request for all documents that have:
meta.createdmeta.updatedmeta.removed
field $gtthan the date I specify ( without$or )?
What I have now:
const d = ISODate("2017-11-20T13:00:00.033Z");
db
.collection('example')
.find(
{
$or: ['meta.removed', 'meta.edited', 'meta.created'].map(m => {
return { [m]: { $gt: d } }
})
}
);
What I tried and did not work:
const d = ISODate("2017-11-20T13:09:11.033Z");
db
.collection('example')
.find(
{
'meta.$': { $gt: d }
}
);
source
share