I can get all stats of the site with aggregation
but I want to it for a certain user, like $where
.
All stats:
games.aggregate([{
$group: {
_id: '$id',
game_total: { $sum: '$game_amount'},
game_total_profit: { $sum: '$game_profit'}}
}]).exec(function ( e, d ) {
console.log( d )
})
When I try to use $match
operator, I'm getting error :
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
What am I missing?