MongoDB 8 · Aggregation

Join another collection

Add matching users to each order, like a left outer join.

db.orders.aggregate([
  { $lookup: { from: "users", localField: "userId", foreignField: "_id", as: "user" } }
])

Official MongoDB 8 documentation

More aggregation commands

All aggregation commands · MongoDB 8 cheatsheet

Was this page helpful?