$lookup

noun

say it: “DOL-er LUK-up” /ˈdɑlər ˈlʊkʌp/

A MongoDB aggregation stage that adds the matching documents from another collection to each document, like a join.

What does $lookup do?

$lookup joins documents from another collection into each document, like a left outer join.

{ $lookup: { from: 'customers', localField: 'customerId', foreignField: '_id', as: 'customer' } }

In a sentence

  • “$lookup added each order's customer document as an array called customer.”
  • “After $lookup, $unwind turned the one-item array into a plain field.”

Level: Journeyman · More MongoDB terms at this level

Updated