Pipeline Practice

Attach customer context

`$lookup` joins documents from another collection into an array. When the relationship is one-to-one, unwind the match before shaping the result.

Attach each customer, then return `orderId`, `customerName`, `segment`, and `total`.

Expected result: 12 enriched order documents.

Example pipeline syntax

[
  { $lookup: { from: "customers", localField: "customerId", foreignField: "_id", as: "customer" } }
]