AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

db.dropAllUsers()(mongoshメソッド)

db.dropAllUsers(writeConcern)

現在のデータベースからすべてのユーザーを削除します。

重要

mongosh メソッド

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

データベースコマンドについては、dropAllUsersFromDatabase コマンドを参照してください。

MongoDB API ドライバーについては、各言語の「MongoDB ドライバーのドキュメント」を参照してください。

警告

The db.dropAllUsers() method removes all users from the database.

The db.dropAllUsers() method takes the following arguments:

フィールド
タイプ
説明

writeConcern

ドキュメント

任意。 操作の 書込み保証( write concern ) のレベル。 詳しくは、 書込み保証(write concern) の仕様を参照してください。

The db.dropAllUsers() method wraps the dropAllUsersFromDatabase command.

このメソッドは、次の環境でホストされている配置で使用できます。

重要

このコマンドは、MongoDB Atlas クラスターではサポートされていません。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。

  • MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン

  • MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン

If run on a replica set, db.dropAllUsers() is executed using "majority" write concern by default.

データベースからユーザーを削除するには、データベースに対して dropUser アクションが必要です。

The following db.dropAllUsers() operation drops every user from the products database.

use products
db.dropAllUsers( {w: "majority", wtimeout: 5000} )

結果ドキュメントのnフィールドには、削除されたユーザーの数が表示されます。

{ "n" : 12, "ok" : 1 }