Count in MongoDB

Count returns the number of documents in the collection, it can either used with collection or else with find()  command.

Example:  

                         

db.studentDetails.count()

The above Query will give the total count in studentDetails collection.

                        

db.studentDetails.find({Department:'CSE'}).count()

The above Command will give the count of StudentDetails collection with ‘Department’ key is ‘CSE’