定义
db.dropAllRoles( writeConcern )删除运行该方法的数据库上的所有用户定义角色。
警告
The
db.dropAllRoles()method removes all user-defined roles from the database.重要
mongosh 方法
This page documents a
mongoshmethod. This is not the documentation for database commands or language-specific drivers, such as Node.js.有关数据库命令,请参阅
dropAllRolesFromDatabase命令。如需了解 MongoDB API 驱动程序,请参阅特定语言的 MongoDB 驱动程序文档。
The
db.dropAllRoles()method takes the following argument:返回: 删除的用户定义角色的数量。
兼容性
此方法可用于以下环境中托管的部署:
重要
MongoDB Atlas 集群不支持此命令。有关 Atlas 对所有命令的支持的信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
行为
副本集
If run on a replica set, db.dropAllRoles() is executed using "majority" write concern by default.
必需的访问权限
例子
以下操作从products数据库中删除所有用户定义的角色,并使用写关注majority 。
use products db.dropAllRoles( { w: "majority" } )
该方法返回删除的角色数量:
4