MongoDB Tutorial 0/120 lessons ~6 min read Lesson 52

    Lookup Stage

    $lookup is MongoDB's left-outer join.

    Course progress0%
    Focus
    3 guided sections
    Practice signal
    Examples included
    Career prep
    Foundation builder

    Introduction

    $lookup is MongoDB's left-outer join. It pulls matching documents from another collection into an array field on the current pipeline.

    Syntax reference

    js
    { $lookup: {
    from: "users",
    localField: "userId",
    foreignField: "_id",
    as: "user"
    }}

    Best practices

    • Index the foreignField.
    • Limit lookup output with a sub-pipeline.
    Ready to mark this lesson complete?Track your journey across the entire course.