定義
db.revokeRolesFromRole(rolename, roles, writeConcern)指定された継承ロールをロールから削除します。
重要
mongosh メソッド
This page documents a
mongoshmethod. This is not the documentation for database commands or language-specific drivers, such as Node.js.データベースコマンドについては、
revokeRolesFromRoleコマンドを参照してください。MongoDB API ドライバーについては、各言語の「MongoDB ドライバーのドキュメント」を参照してください。
The
db.revokeRolesFromRole()method uses the following syntax:db.revokeRolesFromRole( "<rolename>", [ <roles> ], { <writeConcern> } ) The
db.revokeRolesFromRole()method takes the following arguments:Parameterタイプ説明rolenamestring
ロールを取り消すロールの名前。
roles配列
削除する継承されたロール。
writeConcernドキュメント
任意。 操作の 書込み保証( write concern ) のレベル。 詳しくは、 書込み保証(write concern) の仕様を参照してください。
rolesフィールドでは、組み込みロールとユーザー定義ロールの両方を指定できます。To specify a role that exists in the same database where
db.revokeRolesFromRole()runs, you can either specify the role with the name of the role:"readWrite" または、次のように、ドキュメントを使用してロールを指定することもできます。
{ role: "<role>", db: "<database>" } 別のデータベースに存在するロールを指定するには、 ドキュメントを使用してロールを指定します。
互換性
このメソッドは、次の環境でホストされている配置で使用できます。
重要
このコマンドは、MongoDB Atlas クラスターではサポートされていません。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
動作
レプリカセット
If run on a replica set, db.revokeRolesFromRole() is executed using "majority" write concern by default.
必要なアクセス権
データベースのロールを取り消すには、データベースに対してrevokeRoleアクションが必要です。
例
emeaデータベース内のpurchaseAgentsロールは、 roles配列にリストされているように、いくつかの他のロールから特権を継承します。
{ "_id" : "emea.purchaseAgents", "role" : "purchaseAgents", "db" : "emea", "privileges" : [], "roles" : [ { "role" : "readOrdersCollection", "db" : "emea" }, { "role" : "readAccountsCollection", "db" : "emea" }, { "role" : "writeOrdersCollection", "db" : "emea" } ] }
The following db.revokeRolesFromRole() operation on the emea database removes two roles from the purchaseAgents role:
use emea db.revokeRolesFromRole( "purchaseAgents", [ "writeOrdersCollection", "readOrdersCollection" ], { w: "majority" , wtimeout: 5000 } )
purchaseAgentsロールには現在、次のロールが 1 つだけ含まれています。
{ "_id" : "emea.purchaseAgents", "role" : "purchaseAgents", "db" : "emea", "privileges" : [], "roles" : [ { "role" : "readAccountsCollection", "db" : "emea" } ] }