0
このMeteorサーバーコードは、文書をグループ化し、「期間」の昇順でソートしようとしますが、それを修正する方法はありません。 THXmeteorhacksで文書を並べ替える方法:集計出力
let invoicePopulation = UsageCol.aggregate([
{
$match: {
action: {$in: ['a', 'b', 'c']},
userId: doc.userId
}
},
{
$group: {
_id: {period: "$period"},
count: {$sum: 1}
}
},
{
"$sort" : {
"period" : 1
}
}
]);
//output
[{"_id":{"period":"42017"},"count":14},{"_id":{"period":"22017"},"count":1},{"_id":{"period":"32017"},"count":271}]
//needs to be
[{"_id":{"period":"22017"},"count":1},{"_id":{"period":"32017"},"count":271},{"_id":{"period":"42017"},"count":14}]