dropRole

On this page本页内容

Definition定义

dropRole

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

The dropRole command uses the following syntax:dropRole命令使用以下语法:

{
  dropRole: "<role>",
  writeConcern: { <write concern> },
  comment: <any>
}

The dropRole command has the following fields:dropRole命令包含以下字段:

Field字段Type类型Description描述
dropRolestringThe 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.请参阅写入关注规范

commentany

Optional. 可选。A user-provided comment to attach to this command. 用户提供了附加到此命令的注释。Once set, this comment appears alongside records of this command in the following locations:设置后,此注释将与此命令的记录一起显示在以下位置:

A comment can be any valid BSON type(string, integer, object, array, etc).注释可以是任何有效的BSON类型(字符串、整数、对象、数组等)。

New in version 4.4.在版本4.4中新增

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.runCommand(
   {
     dropRole: "readPrices",
     writeConcern: { w: "majority" }
   }
)
←  createRoledropAllRolesFromDatabase →