# Arrays and Joins in a Pipeline

Arrays and Joins in a Pipeline: $unwind: One Document per Array Item, $lookup: Bringing in Related Documents.

Updated: November 19, 2026

1. [$unwind: One Document per Array Item](https://www.ask-codey.com/lessons/mongodb-aggregation-unwind) (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.
2. [$lookup: Bringing in Related Documents](https://www.ask-codey.com/lessons/mongodb-aggregation-lookup) (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.

Source: https://www.ask-codey.com/courses/mongodb-in-depth/topics/mongodb-arrays-and-joins-in-pipelines
