Arrays and Joins in a Pipeline
Arrays and Joins in a Pipeline: $unwind: One Document per Array Item, $lookup: Bringing in Related Documents.
Updated
- $unwind: One Document per Array Item (Journeyman): $unwind turns a document with an array into one document per item, so a pipeline can count, group and total the items themselves, such as the units of each product sold across every order.
- $lookup: Bringing in Related Documents (Journeyman): $lookup brings matching documents from another collection into each document of a pipeline, such as each order's customer, as an array you can unwind, and a lookup a screen needs on every read is a sign to embed or copy those fields instead.