dropAllUsersFromDatabase
On this page本页内容
Definition定义
dropAllUsersFromDatabase
-
Removes all users from the database on which you run the command.从运行命令的数据库中删除所有用户。TipIn
mongosh
, this command can also be run through thedb.dropAllUsers()
helper method.Helper methods are convenient for
mongosh
users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.WarningThe
dropAllUsersFromDatabase
removes all users from the database.
Syntax语法
The command has the following syntax:该命令具有以下语法:
db.runCommand(
{
dropAllUsersFromDatabase: 1,
writeConcern: { <write concern> },
comment: <any>
}
)
Command Fields命令字段
The command takes the following fields:该命令包含以下字段:
dropAllUsersFromDatabase | integer | Specify 1 to drop all the users from the current database. |
writeConcern | document | |
comment | any |
|
Required Access所需访问权限
You must have the dropUser
action on a database to drop a user from that database.
Example实例
The following sequence of operations in mongosh
drops every user from the products
database:
use products
db.runCommand( { dropAllUsersFromDatabase: 1, writeConcern: { w: "majority" } } )
The 结果文档中的n
field in the results document shows the number of users removed:n
字段显示删除的用户数:
{ "n" : 12, "ok" : 1 }