ANNOUNCEMENT: Voyage AI joins MongoDB to power more accurate and trustworthy AI applications on Atlas.
Learn more
Docs Menu

db.dropAllRoles()

db.dropAllRoles( writeConcern )

Deletes all user-defined roles on the database where you run the method.

警告

The db.dropAllRoles() method removes all user-defined roles from the database.

重要

mongosh メソッド

このページでは、mongosh メソッドについて記載しています。ただし、データベースコマンドや Node.js などの言語固有のドライバーのドキュメントには該当しません

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

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

The db.dropAllRoles() method takes the following argument:

フィールド
タイプ
説明

writeConcern

ドキュメント

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

次の値を返します。The number of user-defined roles dropped.

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

重要

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

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

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

レプリカセットで実行する場合、 db.dropAllRoles()はデフォルトで"majority"書込み保証を使用して実行されます。

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

The following operations drop all user-defined roles from the products database and uses a 書込み保証 (write concern) of majority.

use products
db.dropAllRoles( { w: "majority" } )

The method returns the number of roles dropped:

4