【发布时间】:2021-12-27 13:14:49
【问题描述】:
我有以下文件。
[
{
"content": {
"abc123": {
"_id": "abc123",
"total": 189,
"published": 189,
"created": 0,
"approved": 0,
"rejected": 0,
"sent_for_approval": 0
},
"abc124": {
"_id": "abc124",
"total": 1911,
"published": 1899,
"created": 10,
"approved": 2,
"rejected": 0,
"sent_for_approval": 0
}
}
},
{
"content": {
"abc124": {
"_id": "abc124",
"total": 1911,
"published": 1899,
"created": 10,
"approved": 2,
"rejected": 0,
"sent_for_approval": 0
}
}
}
]
如何将这个键值对对象转换成单独的文档,如下所示,不重复enter code here:
[
{
"_id": "abc123",
"total": 189,
"published": 189,
"created": 0,
"approved": 0,
"rejected": 0,
"sent_for_approval": 0
},
{
"_id": "abc124",
"total": 1911,
"published": 1899,
"created": 10,
"approved": 2,
"rejected": 0,
"sent_for_approval": 0
}
]
【问题讨论】:
标签: mongodb mongodb-query aggregation-framework