On this page本页内容
db.
getRoles
()¶Returns information for all the roles in the database on which the command runs. 返回运行命令的数据库中所有角色的信息。The method can be run with or without an argument.该方法可以带参数运行,也可以不带参数运行。
If run without an argument, 如果在没有参数的情况下运行,db.getRoles()
returns inheritance information for the database’s user-defined roles.db.getRoles()
将返回数据库用户定义角色的继承信息。
To return more information, pass the 要返回更多信息,请向db.getRoles()
a document with the following fields:db.getRoles()
传递包含以下字段的文档:
rolesInfo |
integer | 1 to retrieve all user-defined roles.1 以检索所有用户定义的角色。 |
showPrivileges |
boolean | true to show role privileges, including both privileges inherited from other roles and privileges defined directly. true 以显示角色权限,包括从其他角色继承的权限和直接定义的权限。 |
showBuiltinRoles |
boolean | true 可显示内置角色和用户定义的角色。 |
db.getRoles()
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 operations return documents for all the roles on the 以下操作返回products
database, including role privileges and built-in roles:products
数据库中所有角色的文档,包括角色权限和内置角色: