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描述
rolenamestringThe name of the user-defined role to remove from the database.要从数据库中删除的用户定义角色的名称。
writeConcerndocument

Optional. 可选。The level of write concern for the operation. 操作的写入关注级别。See Write Concern Specification.请参阅写入关注规范

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" } )
←  db.createRole()db.dropAllRoles() →