如何在集合的所有文档中获取不同的现有密钥

时间:2017-03-02 05:47:57

标签: mongodb mongodb-query

我有以下userRole集合,其中在单个对象中找到了来自此集合的associatePermission对象的不同键。

e.g。如果我在此对象中传递2或3个角色,或者所有角色都希望将这些角色的所有权限合并到一个对象中。

"userRole":{
"_id" : ObjectId("58902f6b5d474004b4034026"),
"roleName" : "Filler",
"permission" : {
    "ActionPermissions" : {
        "Incidence Management" : {
            "Trouble Ticketing" : {
                "Add Ticket" : {}
            }
        }
    }
},
"associatePermission" : {
    "ActionPermissions" : {
        "Incidence Management" : {
            "Trouble Ticketing" : {
                "Add Ticket" : {},
                "Bulk Closure" : true
            },
            "Ageing Report" : {
                "Filter Report" : true
            }
        },
        "Preventive Maintenance" : {
            "Edit Ticket" : {
                "Severity" : true
            }
        }
    },
    "DataPermissions" : {
        "Incidence Management" : {
            "Trouble Ticketing" : {
                "Add Ticket" : {}
            }
        }
    }
 }
},

{
    "_id" : ObjectId("58902f6b5d474556565"),
    "roleName" : "Filler",
    "permission" : {
        "ActionPermissions" : {
            "Incidence Management" : {
                "Trouble Ticketing" : {
                    "Add Ticket" : {}
                }
            }
        }
    },
    "associatePermission" : {
        "ActionPermissions" : {
            "Incidence Management" : {
                "Trouble Ticketing" : {
                    "Add Ticket" : {},
                    "Bulk Closure" : true
                },
                "Ageing Report" : {
                    "Filter Report" : true
                }
            },
            "Preventive Maintenance" : {
                "Edit Ticket" : {true}
            }
        },
        "DataPermissions" : {
            "Incidence Management" : {
                "Trouble Ticketing" : {
                    "Add Ticket" : {}
                }
            }
        }
    }
}

0 个答案:

没有答案