Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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"
}])
 
PREVIOUS NEXT
Tagged: #mongodb #aggregate #count
ADD COMMENT
Topic
Name
1+6 =