Skip to content
Justice Tech School

Counting

countDocuments counts matches.

Example
db.users.countDocuments({ age: { $gt: 20 } })
db.users.estimatedDocumentCount()

Exercise

Count with filter.

db.users.({})

Quiz Test

Which is fastest without a filter?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.