我得到的聚合结果(两个对象的数组)如下所示:
[
{
"immunizationDetails": [
[
"Rubella"
],
[
"PCV13",
"Tdap"
]
]
},
{
"immunizationDetails": [
[
"Hepatitis B",
"HIB"
],
[
"PCV13"
]
]
}
]
但我需要immunizationDetails位于单个数组中,如下所示:
[
{
"immunizationDetails": ["Rubella", "PCV13", "Tdap"]
},
{
"immunizationDetails": ["Hepatitis B", "HIB", "PCV13"]
}
]
需要某人有价值的帮助。
1条答案
按热度按时间wgeznvg71#
只需将
$reduce
与$concatArrays
再相加一个即可使结果变平。Mongo Playground