What do lookup, unwind and facet do?
Understand the concept
$lookup adds related data from another collection, $unwind expands an array into individual output records, and $facet runs multiple sub-pipelines on the same input. These operations change the shape or number of documents flowing through a pipeline. They are useful for joins and reports but can increase memory use and intermediate result size.
Important ideas
-
$lookupadds matching data from another collection. -
$unwindturns array items into separate output documents. -
$facetproduces multiple grouped outputs, such as a page and a count. -
Unwinding an array of ten items can turn one document into ten; choose whether empty arrays should be preserved.
Can you explain it without the notes?
What do lookup, unwind and facet do?
Use your own words. Explain an example and one limitation before checking the explanation.
Check your explanation
$lookup adds related data from another collection, $unwind expands an array into individual output records, and $facet runs multiple sub-pipelines on the same input. These operations change the shape or number of documents flowing through a pipeline. They are useful for joins and reports but can increase memory use and intermediate result size.
Turn this concept into a clear answer.
- Explain row multiplication and what it does to later counts or sums, not just the operator names.
Adapted from 04_MONGODB_MONGOOSE.md · “What do lookup, unwind and facet do?”. Examples are study fragments; framework behavior can depend on your version.