$match (filter) and the total
db.simple.aggregate( [
{ $match : { name: "foo" } },
{ $group: { _id: "total", total: { $sum : "$cnt" } } }
] )
{
"result": [
{
"_id": "total",
"total": 12
}
],
"ok": 1
}
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
db.simple.aggregate( [
{ $match : { name: "foo" } },
{ $group: { _id: "total", total: { $sum : "$cnt" } } }
] )
{
"result": [
{
"_id": "total",
"total": 12
}
],
"ok": 1
}