Grokking MongoDB
Vote

0% completed

​

MongoDB Aggregation $lookup

A paper receipt that shows only a customer number tells you little until someone finds that number in the customer list. Orders in MongoDB are often stored the same way: each order holds a customer_id, and the name and age are in a customers collection. The $lookup stage does this search for each document in a pipeline and adds what it finds to the document. This operation is called a join.

Here are the two collections for this lesson, with the same fruit shop orders.

db.customers.drop() db.orders.drop() db.customers.insertMany([

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content