We have various options to count documents in MongoDB. Some of them includes:
db.collection.countDocuments()
db.collection.estimatedDocumentCount()
db.collection.count()
examples:
db.users.countDocuments({}) db.users.estimatedDocumentCount({}) db.users.count({})
the_reactor Answered question 28/02/2022