db.dropRole()

On this page本页内容

Definition定义

db.dropRole(rolename, writeConcern)

Deletes a user-defined role from the database on which you run the method.从运行该方法的数据库中删除用户定义的角色。

The db.dropRole() method takes the following arguments:db.dropRole()方法采用以下参数:

Parameter参数Type类型Description描述
rolename string The name of the user-defined role to remove from the database.要从数据库中删除的用户定义角色的名称。
writeConcern document Optional.可选。The level of write concern for the removal operation. 删除操作的写入关注级别。The writeConcern document takes the same fields as the getLastError command.writeConcern文档采用与getLastError命令相同的字段。

The db.dropRole() method wraps the dropRole command.db.dropRole()方法包装dropRole命令。

Behavior行为

Replica set复制集

If run on a replica set, db.dropRole() is executed using majority write concern by default.如果在副本集上运行,默认情况下,db.dropRole()将使用majority写入关注点执行。

Required Access所需访问权限

You must have the dropRole action on a database to drop a role from that database.必须对数据库执行dropRole操作才能从该数据库中删除角色。

Example示例

The following operations remove the readPrices role from the products database:以下操作将从products数据库中删除readPrices角色:

use products
db.dropRole( "readPrices", { w: "majority" } )