db.dropRole()
定义
db.dropRole( rolename, writeConcern )
Deletes a user-defined role from the database on which you run the method.
重要
mongosh 方法
本页面提供
mongosh
方法的相关信息。这不是数据库命令或特定语言驱动程序(例如 Node.js)的相关文档。有关数据库命令,请参阅
dropRole
命令。如需了解 MongoDB API 驱动程序,请参阅特定语言的 MongoDB 驱动程序文档。
db.dropRole()
方法接受以下参数:Parameter类型说明rolename
字符串
The name of the user-defined role to remove from the database.
writeConcern
文档
兼容性
此方法可用于以下环境中托管的部署:
重要
MongoDB Atlas集群不支持此命令。 有关Atlas支持所有命令的信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
行为
身份验证
When a role is dropped on a mongod
, previously authenticated users
remain logged in to the database but immediately lose the role's privileges.
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. The cache refreshes automatically after the time specified with the
userCacheInvalidationIntervalSecs
parameter or manually when
you run the invalidateUserCache
command.
副本集(Replica Set)
如果在副本集上运行,则默认情况下使用 "majority"
写关注执行
db.dropRole()
。
必需的访问权限
例子
The following operations remove the readPrices
role from the
products
database:
use products db.dropRole( "readPrices", { w: "majority" } )