I have a document like this:
{
"_id": 17995,
"dates": [
"2022-05-05T00:00:00.000+00:00",
"2022-05-09T00:00:00.000+00:00",
"2022-05-31T00:00:00.000+00:00"
]
}
I need to query by date but keep the previous index. For example:
match: {
$gte: ISODate("2022-05-25T00:00:00.000+00:00")
...
}
Should return "2022-05-09T00:00:00.000+00:00", "2022-05-31T00:00:00.000+00:00"
.
Because the range matches "2022-05-31T00:00:00.000+00:00"
and "2022-05-09T00:00:00.000+00:00"
is the previous one. How to do that with the aggregation framework?