Counting
countDocuments counts matches.
Example
db.users.countDocuments({ age: { $gt: 20 } })
db.users.estimatedDocumentCount()Exercise
Count with filter.
db.users.({})
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.