LESSON 10 / 20·2 min readIntermediate

What do lookup, unwind and facet do?

01 Understand02 Recall03 Prepare

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

  • $lookup adds matching data from another collection.

  • $unwind turns array items into separate output documents.

  • $facet produces 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.

PAUSE & RECALL

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.

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

  • Explain row multiplication and what it does to later counts or sums, not just the operator names.
Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: What do set, addFields, skip and count do?

Adapted from 04_MONGODB_MONGOOSE.md · “What do lookup, unwind and facet do?”. Examples are study fragments; framework behavior can depend on your version.