I'm trying to get info from an object that is nested within an object in Mongo. The data structure looks like this:
Card{
_id;
contributors: [
{
name;
_id;
},
{
name;
_id;
}
]
}
Here is my attempt at accessing a specific 'contributor' in the 'contributors' array.
Card.findOne({_id: cardId, "contributor._id": contributorId},
(err, contributor) => {
if (err) {
console.log(err);
res.status(500);
res.send({status: "error", message: "sass overload"});
return;
}
console.log(contributor);
res.send(contributor);
});