I have a collection with nested arrays as below:
[
{
"title":"Foo",
"arr":[
[
{
"value":"2021-11-13T00:00:00.000Z",
"baz":10
},
{
"value":"2021-11-12T00:00:00.000Z",
"baz":0
}
]
]
},
{
"title":"Bar",
"arr":[
[
{
"value":"2021-12-03T00:00:00.000Z",
"baz":10
},
{
"value":"2021-12-07T00:00:00.000Z",
"baz":0
}
]
]
}
]
I want to filter out the largest value (i.e., latest date) for each document such that the result is:
[
{
"title": "Foo",
"value": "2021-11-13T00:00:00.000Z",
},
{
"title": "Bar",
"value": "2021-12-07T00:00:00.000Z",
},
]
How can this query be written?