更新权限

> db.users.findOne()
{
    "_id" : ObjectId("51e3e2e16a847147f7ccdf7d"),
    "user" : "testAdmin",
    "pwd" : "[some hash]",
    "roles" : [
        "clusterAdmin"
    ],
    "otherDBRoles" : {
        "TestDB" : [
            "readWrite"
        ]
    }
}
> db.users.update({"user" : "testAdmin"}, {$addToSet: {'otherDBRoles.TestDB': 'dbAdmin'}}, false, false)
> db.users.findOne()
{
    "_id" : ObjectId("51e3e2e16a847147f7ccdf7d"),
    "user" : "testAdmin"
    "pwd" : "[some hash]",
    "roles" : [
        "clusterAdmin"
    ],
    "otherDBRoles" : {
        "TestDB" : [
            "readWrite",
            "dbAdmin"
        ]
    },
}

 

你可能感兴趣的:(权限)