Database

[{"key":1},{"key":2}]

Query

db.collection.aggregate([{$group:{_id:"null","count":{$sum:1}}},])

Result