1

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"? Commented Aug 25, 2017 at 19:05

1 Answer 1

1

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 }
    }
}])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.