【发布时间】:2014-12-11 13:25:52
【问题描述】:
我可以使用 aggregation 获取网站的所有统计信息,但我想为特定用户获取它,例如 $where。
所有统计数据:
games.aggregate([{
$group: {
_id: '$id',
game_total: { $sum: '$game_amount'},
game_total_profit: { $sum: '$game_profit'}}
}]).exec(function ( e, d ) {
console.log( d )
})
当我尝试使用 $match 运算符时,我收到了错误:
games.aggregate([{
$match: { '$game_user_id' : '12345789' },
$group: {
_id: '$id',
game_total: { $sum: '$game_amount'},
game_total_profit: { $sum: '$game_profit'}}
}]).exec(function ( e, d ) {
console.log( d )
})
Arguments must be aggregate pipeline operators
我错过了什么?
【问题讨论】:
标签: javascript node.js mongodb mongodb-query aggregation-framework