按照數量返回
db.getCollection("xxxx").aggregate([
{
$match: {
"daily.incomeMap": { $exists: true }
}
},
{
$group: {
_id: "$groupId",
totalCount: { $sum: 1 }
}
},
{
$sort: { totalCount: -1 }
},
{
$limit: 1000
}
])