Answers for "mongo find and count all"

Go
3

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"
}])
Posted by: Guest on February-25-2021
0

count collection mongodb

db.mycollection.count()
Posted by: Guest on April-23-2021

Browse Popular Code Answers by Language