db.parties.aggregate(
[
{
$match:{
"roles":{
$ne:null // []
}
}
},
{
$unwind:"$roles"
},
{
$lookup:{
from:"roles",
localField:"roles",
foreignField:"_id",
as:"roles"
}
}]).pretty();
- https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/
- https://www.compose.io/articles/deeper-into-3-2-lookup/
- http://www.codeproject.com/Articles/1077839/Working-with-MongoDBs-lookup-Aggregator
- https://www.mongodb.com/blog/post/joins-and-other-aggregation-enhancements-coming-in-mongodb-3-2-part-1-of-3-introduction