Skip to content
Justice Tech School

$count and $facet

Count and run sub pipelines.

Example
db.users.aggregate([
  { $match: { active: true } },
  { $count: "active" }
])

Exercise

Count stage.

{ : "n" }

Quiz Test

What does $count output?

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