I am trying to query a array in which a field does not exist or is in the future.
For example I have the following query:
{$or:[{"status.date":{$exists:false}}, {"status.date":{$gt: ISODate('2020-08-25T13:47:20+0000')}}]}
and my collection looks similar to this
{
"status": [{
"date": "2022-08-25T13:47:20+0000",
"a": "test1"
},
{
"date": "2010-08-25T13:47:20+0000",
"a": "test2"
},
{
"a": "test3"
}
]
}
....
The results do not show the above collection because of the "status.date":{$exists:false}} as there is status.date as it exists in status[0] and status[1].
Is there a any other operation I could use to achieve this.
{$or:[{"status.date":{$exists:false}}, {"status.date":{$gt: ISODate('2020-08-25T13:47:20+0000')}}]}but its not getting any results