I Mongo 3.4+ kan du bruge $reduce
at udjævne 2d-arrays.
db.collection.aggregate(
[
{
$project: {
"countries": {
$reduce: {
input: '$Countries',
initialValue: [],
in: {$concatArrays: ['$$value', '$$this']}
}
}
}
}
]
)
Dokumenter:https://docs.mongodb.com/manual/reference/ operatør/aggregation/reducer/