mongodb aggregate and count code example
Example: 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"
}])