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

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

dropRole

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

Tip

In mongosh, this command can also be run through the db.dropRole() 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 Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン

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

重要

This command is not supported in MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.

このコマンドの構文は、次のとおりです。

db.runCommand(
{
dropRole: "<role>",
writeConcern: { <write concern> },
comment: <any>
}
)

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

フィールド
タイプ
説明

dropRole

string

データベースから削除するユーザー定義ロールの名前。

writeConcern

ドキュメント

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

comment

any

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

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

mongodでロールが削除されると、以前に認証されたユーザーは データベースにログインしたままですが、ロールの特権をすぐに失います。

mongosでロールが削除されても、以前に認証されたユーザーは データベースにログインしたままですが、 キャッシュ が更新されるとロールの特権が失われます。 キャッシュは、 userCacheInvalidationIntervalSecsパラメータで指定された時間の後に自動的に更新されるか、 invalidateUserCacheコマンドを実行すると手動で更新されます。

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

次の操作により、 productsデータベースからreadPricesロールが削除されます。

use products
db.runCommand(
{
dropRole: "readPrices",
writeConcern: { w: "majority" }
}
)