$lookup
Reference group: Pipeline stages
What it does
Joins matching documents from another collection into an array.
Syntax
{$lookup: { from, localField, foreignField, as }}
Use case
Combine related collections.
$lookup: practical example
{ $lookup: { from: "customers", localField: "customerId", foreignField: "_id", as: "customer" } }💡 Explanation
Joins matching documents from another collection into an array.
When to use it
Combine related collections.
Key Takeaways
- Joins matching documents from another collection into an array.
- Typical use: Combine related collections.