MongoDB: Lookup and Aggregate: Reference Model

db.Reviews.drop();

db.Reviews.insertMany([
 
    {_id:1, rating:5, comment: "overall not bad"},
    {_id:2, rating:2, comment: "overall not bad"},
    {_id:3, rating:3, comment: "overall not bad"},
    {_id:4, rating:5, comment: "overall not bad"},
    {_id:5, rating:4, comment: "overall not bad"},
    {_id:6, rating:5, comment: "overall not bad"}
 
]);  

db.ProductRefModel.drop(); 
db.ProductRefModel.insertMany([
    {
        ProductId:1,
        Description: "Bottle",
        ReviewIds: [ 1, 2 ]
    },
    {
        ProductId: 2,
        Description: "Air Pump",
        ReviewIds: [3,4]
    }
    ]);
    
    
db.ProductRefModel.find();
 
db.ProductRefModel.aggregate([
    {
        $lookup: {
            from: "Reviews",
            localField: "ReviewIds",
            foreignField: "_id",
            as: "Rating Details"
        }
    }
  ]
); 


db.Reviews.aggregate([
    {
        $lookup: {
            from: "ProductRefModel",
            localField: "_id",
            foreignField: "ReviewIds",
            as: "Product Details"
        }
    }
  ]
);