MongoDB 8 · Create, read, update, delete

Count matching documents

Count the documents that match a filter.

db.users.countDocuments({ active: true })

Official MongoDB 8 documentation

More create, read, update, delete commands

All create, read, update, delete commands · MongoDB 8 cheatsheet

Was this page helpful?