MongoDB Left Outer Join with aggregation ( $Lookup)


Example

let col_1 = db.collection('col_1');
let col_2 = db.collection('col_2');      
col_1 .aggregate([
    { $match: { "_id": 1 } },
    {
        $lookup: {
            from: "col_2",
            localField: "id",
            foreignField: "id",
            as: "new_document"
        }
    }
],function (err, result){
    res.send(result);
});

This feature was newly released in the mongodb version 3.2 , which gives the user a stage to join one collection with the matching attributes from another collection

Mongodb $LookUp documentation