【发布时间】:2016-10-10 23:30:12
【问题描述】:
Sale.aggregate({
$match: filter
}, {
$group: {
"_id": {
"store_id": "$store_id",
//"created_on": { $dateToString: { format: "%Y-%m-%d", date: "$strBillDate" } }
},
month: {
$month: "$strBillDate"
},
store_id: {
$first: "$store_id"
},
strBillAmt: {
$sum: "$strBillAmt"
},
strBillNumber: {
$sum: 1
}
}
})
我需要按月分组销售额,而不是日期,nodejs中如何按月分组销售额
【问题讨论】:
-
显示你的数据库结构。
-
store_id: {type: String }, strBillNumber: {type: String },strBillDate: {type: Date },strBillAmt: {type: Number },
标签: node.js mongodb mongoose mongodb-query mongoose-schema