- $avg
Group by name and caluclate average $avg
db.simple.aggregate( [ { $group: { _id: "$name", total: { $avg : "$cnt" } } } ] ) { "result": [ { "_id": "bar", "total": 7 }, { "_id": "foo", "total": 4 } ], "ok": 1 }
db.simple.aggregate( [ { $group: { _id: "$name", total: { $avg : "$cnt" } } } ] ) { "result": [ { "_id": "bar", "total": 7 }, { "_id": "foo", "total": 4 } ], "ok": 1 }