db.collection.aggregate([
{ $unwind: "$items" },
{
"$group": {
"_id": "$_id",
collected:{
$addToSet: "$items.results.collected"
},
}
},
{ $unwind: "$collected" },
{
$project: {
totalcoletado: {
$size: "$collected"
}
}
},
{$sort: { totalcoletado: -1 } },
{$limit: 5}
])
Giga byts
- 11
- 1