Você pode resolver isso com o
$lookup
operador. Considere o seguinte pipeline de agregação:// Execute aggregate, notice the pipeline is expressed as an Array
collection.aggregate([
{
"$lookup": {
"from": "product",
"localField": "content.product.$id",
"foreignField": "_id",
"as": "products"
}
},
{
"$lookup": {
"from": "clients",
"localField": "content.client.$id",
"foreignField": "_id",
"as": "clients"
}
},
], function(err, result) {
console.log(result);
});