I have a json file that look like this in my collection :
[
{
"change":"00001",
"patchset":"4"
},
//etc
]
Two different object can have the same "change" properties. So first I want to group them by "change" properties and inside this group I want the highest value of the "patchset" properties. I have managed to do this easily with this command
db.collections.aggregate([{$group:{_id:"$change",patchset_max:{$max:"$patchset"}}}])
but then, and this is where I lost it, with this max patchset, I want to get all the objects where object.patchset = max_patchset but still in the group array.
I tried with $filter and $match and then nested $group but nothing works,
Do you guys have any idea ?
Thanks