【问题】
Hi,
i am trying to use mongodb aggregate query using $setUnion, $project and also $group to group the documents. The structure of document is
{
“_id” : ObjectId(“55014006e4b0333c9531043e”),
“acls” : {
“append” : {
“users” : [ObjectId(“54f5bfb0336a15084785c393”) ],
“groups” : [ ]
},
“edit” : {
“groups” : [ ],
“users” : [
ObjectId(“54f5bfb0336a15084785c392”)
]
},
“fullControl” : {
“users” : [ ],
“groups” : [ ]
},
“read” : {
“users” : [ObjectId(“54f5bfb0336a15084785c392”), ObjectId(“54f5bfb0336a15084785c398”)],
“groups” : [ ]
}
},
name: “ABC”
}
{
“_id” : ObjectId(“55014006e4b0333c9531043f”),
“acls” : {
“append” : {
“users” : [ObjectId(“54f5bfb0336a15084785c365”) ],
“groups” : [ ]
},
“edit” : {
“groups” : [ ],
“users” : [
ObjectId(“54f5bfb0336a15084785c392”)
]
},
“fullControl”

在MongoDB中尝试使用$setUnion、$project和$group聚合查询,以根据名称分组文档并合并'acls'子文档的'users'字段。集算器提供了一种更直观的方式来实现这个需求,通过在A3步骤按'name'分组,在A4步骤将每个组的'acls'数据合并为'readUser'序列。
最低0.47元/天 解锁文章
678

被折叠的 条评论
为什么被折叠?



