Database

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

Query

db.collection.aggregate([{$facet:{docs:[{$match:{}}],count:[{$count:"count"}]}},{$addFields:{count:{$arrayElemAt:["$count.count",0]}}}])

Result