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

dropAllRolesFromDatabase (データベースコマンド)

dropAllRolesFromDatabase

コマンドを実行するデータベース上のすべてのユーザー定義ロールを削除します。

警告

The dropAllRolesFromDatabase removes all user-defined roles from the database.

Tip

In mongosh, this command can also be run through the db.dropAllRoles() 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.

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

  • 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(
{
dropAllRolesFromDatabase: 1,
writeConcern: { <write concern> },
comment: <any>
}
)

コマンドには次のフィールドがあります:

フィールド
タイプ
説明

dropAllRolesFromDatabase

integer

コマンドが実行されるデータベースからすべてのユーザー定義ロールを削除するには、 1を指定します。

writeConcern

ドキュメント

/includes/source/fact-write-concern-spec-link.rst

comment

any

任意。このコマンドに添付するユーザー指定のコメント。設定すると、このコメントは以下の場所にこのコマンドの記録と合わせて表示されます。

コメントには、有効な BSON 型(string, integer, object, array など)を使用できます。

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

次の操作により、 productsデータベースからすべてのユーザー定義ロールが削除されます。

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

結果ドキュメントのnフィールドは、削除されたロールの数を報告します。

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