On this page本页内容
db.getRole(rolename, args)
Returns the roles from which this role inherits privileges. 返回此角色继承其权限的角色。Optionally, the method can also return all the role's privileges.可选地,该方法还可以返回角色的所有权限。
Run 从包含角色的数据库运行db.getRole()
from the database that contains the role. db.getRole()
。The command can retrieve information for both user-defined roles and built-in roles.该命令可以检索用户定义角色和内置角色的信息。
The db.getRole()
method accepts the following parameters:db.getRole()
方法接受以下参数:
rolename | string | |
args | document |
The args
document supports the following fields:args
文档支持以下字段:
showBuiltinRoles | boolean | rolesInfo field is set to 1 , set showBuiltinRoles to true to include built-in roles in the output. rolesInfo 字段设置为1 时,将showBuildinRoles 设置为true 以在输出中包含内置角色。false , and the output for rolesInfo: 1 displays only user-defined roles.false ,rolesInfo:1 的输出仅显示用户定义的角色。
|
showPrivileges | boolean | true to show role privileges, including both privileges inherited from other roles and privileges defined directly. true 以显示角色权限,包括从其他角色继承的权限和直接定义的权限。 |
db.getRole()
wraps the 包装了rolesInfo
command.rolesInfo
命令。
To view a role's information, you must be either explicitly granted the role or must have the 要查看角色的信息,必须明确授予您该角色,或者必须对角色的数据库执行viewRole
action on the role's database.viewRole
操作。
The following operation returns role inheritance information for the role 以下操作返回associate
defined on the products
database:products
数据库中定义的角色associate
角色继承信息:
use products
db.getRole( "associate" )
The following operation returns role inheritance information and privilegesfor the role 以下操作返回associate
defined on the products
database:products
数据库中定义的角色associate
角色继承信息和权限:
use products db.getRole( "associate", { showPrivileges: true } )