Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumMongoDB$facet multi-pipelineSingle-choice MCQ

Given the aggregation below run over a `products` collection, what is true about how the two sub-pipelines in `$facet` execute and what the output looks like?

db.products.aggregate([ { $match: { active: true } }, { $facet: { byCategory: [ { $group: { _id: "$category", n: { $sum: 1 } } } ], priceStats: [ { $group: { _id: null, avg: { $avg: "$price" }, max: { $max: "$price" } } } ] } } ])