【发布时间】:2025-12-24 09:55:16
【问题描述】:
【问题讨论】:
标签: mongodb mongodb-query aggregation-framework aggregate
【问题讨论】:
标签: mongodb mongodb-query aggregation-framework aggregate
您可以在$facet 之后使用$project、$unwind 和$replaceRoot 聚合管道阶段
db.collection.aggregate([
{ "$project": {
"data": { "$concatArrays": ["$all", "$part"] }
}},
{ "$unwind": "$data" },
{ "$replaceRoot": { "newRoot": "$data" } }
])
【讨论】: