$lookup

Similar to an SQL LEFT OUTER JOIN, $lookup allows you to incorporate documents from another collection. The following example shows a purchases document with an embedded joined customers document. In this example, there are three stages: $lookup, $limit, and $project. Note that in the $project stage we suppress the already embedded customer field as it only contains a partial subset of customer information:

Get MongoDB 4 Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.