dropAllRolesFromDatabase

On this page本页内容

Definition定义

dropAllRolesFromDatabase

Deletes all user-defined roles on the database where you run the command.删除运行命令的数据库中所有用户定义的角色。

Warning警告

The dropAllRolesFromDatabase removes alluser-defined roles from the database.dropAllRolesFromDatabase从数据库中删除所有用户定义的角色。

The dropAllRolesFromDatabase command takes the following form:dropAllRolesFromDatabase命令采用以下形式:

{
  dropAllRolesFromDatabase: 1,
  writeConcern: { <write concern> },
  comment: <any>
}

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

Field字段Type类型Description描述
dropAllRolesFromDatabaseintegerSpecify 1 to drop all user-defined roles from the database where the command is run. 指定1可从运行命令的数据库中删除所有用户定义的角色。
writeConcerndocument/includes/source/fact-write-concern-spec-link.rst
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 drop all user-defined roles from the products database:以下操作将从products数据库中删除所有用户定义的角色:

use products
db.runCommand(
   {
     dropAllRolesFromDatabase: 1,
     writeConcern: { w: "majority" }
   }
)

The n field in the results document reports the number of roles dropped:结果文档中的n字段报告丢弃的角色数:

{ "n" : 4, "ok" : 1 }
←  dropRolegrantPrivilegesToRole →