db.dropRole()
On this page本页内容
Definition定义
db.dropRole( rolename, writeConcern )-
Deletes a user-defined role from the database on which you run the method.从运行该方法的数据库中删除用户定义的角色。Importantmongosh Method
This page documents a
mongoshmethod. This is not the documentation for database commands or language-specific drivers, such as Node.js.For the database command, see the
dropRolecommand.For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.
For the legacy
mongoshell documentation, refer to the documentation for the corresponding MongoDB Server release:Thedb.dropRole()method takes the following arguments:db.dropRole()方法采用以下参数:Parameter参数Type类型Description描述rolenamestring The name of the user-defined role to remove from the database.要从数据库中删除的用户定义角色的名称。writeConcerndocument Optional.可选的。The level of write concern for the operation.操作的写入关注级别。See Write Concern Specification.请参阅写入关注规范。
Behavior行为
Authentication身份验证
When a role is dropped on a 当一个角色被放到mongod, previously authenticated users remain logged in to the database but immediately lose the role's privileges.mongod上时,以前经过身份验证的用户仍然登录到数据库,但会立即失去该角色的权限。
When a role is dropped on a 当在mongos, previously authenticated users remain logged in to the database but lose the role's privileges when the cache refreshes. mongos上删除角色时,以前经过身份验证的用户仍然登录到数据库,但在缓存刷新时会失去角色的权限。The cache refreshes automatically after the time specified with the 在使用userCacheInvalidationIntervalSecs parameter or manually when you run the invalidateUserCache command.userCacheInvalidationIntervalSecs参数指定的时间后,缓存会自动刷新,或者在运行invalidateUserCache命令时手动刷新。
Replica Set复制副本集
If run on a replica set, 如果在副本集上运行,db.dropRole() is executed using "majority" write concern by default.db.dropRole()在默认情况下使用"majority"写入关注执行。
Required Access所需访问权限
You must have the 必须对数据库执行dropRole action on a database to drop a role from that database.dropRole 操作才能从该数据库中删除角色。
Example实例
The following operations remove the 以下操作将从readPrices role from the products database:products数据库中删除readPrices角色:
use products
db.dropRole( "readPrices", { w: "majority" } )