I cannot figure out how to do the aggregation in compass on the following data for which I want:
I want only these documents where the last element of the ‘versions’ array has ‘version_status’ = ‘MERGED’ and return the entire document.
{
"_id": {
"$oid": "6407581b1f37c526aa6e0af3"
},
"field1": "12211",
"field2": "ABC",
"field3": "ABC",
"field4": "ABC",
"versions": [{
"version": "1",
"version_create_datetime": "202303071028",
"version_created_by": "ENTITY",
"version_source_file": "123.txt",
"version_status": "MERGED",
"my_data": {
"field4": "01",
"field4": "04",
"field4": "03",
}
}]
}
Thanks!