定義
dropAllUsersFromDatabaseコマンドを実行するデータベースからすべてのユーザーを削除します。
Tip
In
mongosh, this command can also be run through thedb.dropAllUsers()helper method.Helper methods are convenient for
mongoshusers, 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.警告
The
dropAllUsersFromDatabaseremoves all users from the database.
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
重要
This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
構文
このコマンドの構文は、次のとおりです。
db.runCommand( { dropAllUsersFromDatabase: 1, writeConcern: { <write concern> }, comment: <any> } )
コマンドフィールド
このコマンドは、次のフィールドを使用します。
フィールド | タイプ | 説明 |
|---|---|---|
| integer | 現在のデータベースからすべてのユーザーを削除するには、 |
| ドキュメント | 任意。 操作の 書込み保証( write concern ) のレベル。 詳しくは、 書込み保証(write concern) の仕様を参照してください。 |
| any | 任意。このコマンドに添付するユーザー指定のコメント。設定すると、このコメントは以下の場所にこのコマンドの記録と合わせて表示されます。
コメントには、有効な BSON 型(string, integer, object, array など)を使用できます。 |
必要なアクセス権
例
The following sequence of operations in mongosh drops every user from the products database:
use products db.runCommand( { dropAllUsersFromDatabase: 1, writeConcern: { w: "majority" } } )
結果ドキュメントのnフィールドには、削除されたユーザーの数が表示されます。
{ "n" : 12, "ok" : 1 }