I have the following query which gets the data that has date.start_time greater than new Date().getTime() - 1000 * 60 * 60 * 24 * 365
Here is the query:
query = EoCHistory.find({
$and: [
{ $or: ors },
{ 'date.start_time': { $gt: new Date().getTime() - 1000 * 60 * 60 * 24 * 365 } },
],
});
I want to also include all those entries that DO NOT have date.start_time
How can this be achieved?
What I tried is:
query = EoCHistory.find({
$and: [
{ $or: ors },
{
'date.start_time': {
$or: [{ $gt: new Date().getTime() - 1000 * 60 * 60 * 24 * 365 }, undefined],
},
},
],
});
And
query = EoCHistory.find({
$and: [
{ $or: ors },
{
'date.start_time': {
$or: [{ $gt: new Date().getTime() - 1000 * 60 * 60 * 24 * 365 }, { $exists: false }],
},
},
],
});