Você precisa primeiro
$unwind
as questions
array e então precisa aplicar $lookup
e finalmente use $group
para reverter novamente para a matriz. db.games.aggregate([
{ "$unwind": "$questions" },
{ "$lookup": {
"from": "questions",
"localField": "questions.question_id",
"foreignField": "_id",
"as": "question_data"
}},
{ "$unwind": "$question_data" },
{ "$addFields": {
"question_data.position": "$questions.position",
"question_data.question_id": "$questions.question_id"
}},
{ "$group": {
"_id": "$_id",
"questions": { "$push": "$questions" },
"question_data": { "$push": "$question_data" }
}}
])