$unwind
deconstrueer de rondes-array$project
om verplichte velden weer te geven
db.collection.aggregate([
{ $unwind: "$rounds" },
{
$project: {
GameID: 1,
ComputerName: 1,
max_player_pot: "$rounds.round_values.max_player_pot",
pot_multiple: "$rounds.round_values.pot_multiple"
}
}
])
Een meer dynamische benadering,
$mergeObjects
om verplichte velden van root enround_values
samen te voegen voorwerp$replaceRoot
om bovenstaand samengevoegd object te vervangen door root
db.collection.aggregate([
{ $unwind: "$rounds" },
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
GameID: "$GameID",
ComputerName: "$ComputerName"
},
"$rounds.round_values"
]
}
}
}
])