mongodb aggregate count documents code example
Example 1: mongodb aggregate count
#return the number of documents whose "field" field has a value of A
query = db.collection.aggregate([{
"$match": {
"field": "A"
}
},{
"$count": "number of occurrences"
}])
Example 2: mongo count
db.collection.countDocuments( <query>, <options> )