0
votes

I use this query to find status( "isActive": false) true or false also find age depending on status last count total amount

db.programmershelper.aggregate([{
    $match: {
        "isActive": false
    }
}, {
    $group: {
        _id: "age",
        total: { $count: "$amount" } 
    }
}])

show this message as well assert: command failed: { "ok" : 0, "errmsg" : "unknown group operator '$count'", "code" : 15952, "codeName" : "Location15952" }

following error

aggregate failed
_getErrorWithCode@src/mongo/shell/utils.js:25:13

1
what is age here? and what is "amount"?Naman

1 Answers

1
votes

You can follow the count, sum and average docs for group to find the exact solution per your requriements.

As to what I understood from the question , you want to aggregate based on filter "isActive": false and finding age depending on the last total count.

db.programmershelper.aggregate([{
    $match: {
        "isActive": false
    }
}, {
    $group: {
        _id: "age",
        count: { $sum: 1 }
    }
}])