Mongoose get only objects from array matching element inside the object Mongoose get only objects from array matching element inside the object mongoose mongoose

Mongoose get only objects from array matching element inside the object


You can use this for reference.your code would be something like this:

Review.find({    product_id: '583ae172231f5ec01db5727e'    },    {        reviews: {            $elemMatch: {                fb_id: {                    $in: <array of fb_id>                }            }        }    },    {        _id: 0,        'reviews.$': 1    }, function(err, results) {    if (err) {        throw err;    };    console.log(results)});