MongoDB Tutorial 0/120 lessons ~6 min read Lesson 54
Facet Stage
$facet runs multiple sub-pipelines on the same input in one query.
Course progress0%
Focus
2 guided sections
Practice signal
Concept-first lesson
Career prep
Foundation builder
Introduction
$facet runs multiple sub-pipelines on the same input in one query. Perfect for dashboards that need several slices of the same data.
Syntax reference
js
{ $facet: {byStatus: [ { $group: { _id: "$status", c: { $sum: 1 } } } ],byMonth: [ { $group: { _id: { $month: "$createdAt" }, c: { $sum: 1 } } } ]}}
Ready to mark this lesson complete?Track your journey across the entire course.