$lookup: Joins
$lookup joins another collection like a left outer join. The result is an array of matches, often followed by $unwind.
Example
db.orders.aggregate([
{ $lookup: { from: "customers", localField: "customerId", foreignField: "_id", as: "customer" } },
{ $unwind: "$customer" }
])Exercise
Join stage.
{ $: { from: "customers" } }
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.