0
我需要在mongo中的查詢幫助,我想獲取posts
標籤,其中status: 'accepted
後,將標籤分組並按事件排序。mongodb聚合,組和排序
db.collection('Posts').aggregate([{
$project: {
tags: 1
}
}, {
$unwind: "$tags"
}, {
$group: {
_id: {
tag: "$tags"
},
count: {
$sum: 1
}
}
}], function (error, result) {
// do stuff
});
這工作,但他們不通過count
字段順序,我不知道如何選擇只有那些狀態accepted
職位。有任何想法嗎?