我可以用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 )
})
当我try 使用$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
我错过了什么?