MongoDB — Reporting Project, Leaderboards & $lookup Joins

🍃 MongoDB 7.0+ 🟢 Chapter 34 of 50 📂 Phase 07: Aggregation Framework Pipeline 📅 2026 Edition

Join collections using $lookup left outer joins, sort results, and paginate aggregation results.

1Left Outer Join with $lookup
$lookup Join Example
db.orders.aggregate([
  {
    $lookup: {
      from: "users",          // Foreign collection
      localField: "userId",   // Local key
      foreignField: "_id",    // Foreign key
      as: "userDetails"       // Output array name
    }
  },
  { $unwind: "$userDetails" }
]);
OC
Written by Our Compiler Technical Editorial Team
Reviewed for accuracy & tested on MongoDB 7.0+ Standards · Last updated August 2026