MongoDB & NoSQL (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What is the `$lookup` operator in the Aggregation Pipeline?
junior LevelCode ExamplePipesCI/CD & DevOps
In Simple Words:
$lookup performs a left outer join between two collections in the same database:
javascript
// Join Orders with Customers collection:
db.orders.aggregate([
{
$lookup: {
from: "customers",
localField: "customerId",
foreignField: "_id",
as: "customerDetails"
}
}
]);