$unwindराउंड ऐरे का पुनर्निर्माण करें$projectआवश्यक फ़ील्ड दिखाने के लिए
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"
}
}
])
एक अधिक गतिशील दृष्टिकोण,
$mergeObjectsआवश्यक फ़ील्ड को रूट औरround_values. से मर्ज करने के लिए वस्तु$replaceRootउपरोक्त मर्ज किए गए ऑब्जेक्ट को रूट में बदलने के लिए
db.collection.aggregate([
{ $unwind: "$rounds" },
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
GameID: "$GameID",
ComputerName: "$ComputerName"
},
"$rounds.round_values"
]
}
}
}
])