seniorMongoDB
Explain the use of $facet in Aggregation.
Updated May 1, 2026
Short answer
$facet allows for multi-faceted aggregations within a single stage.
Deep explanation
It processes multiple aggregation pipelines in parallel on the same set of input documents. This is great for dashboards needing multiple counts.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro