- Reference >
mongoShell Methods >- Role Management Methods >
- db.dropAllRoles()
db.dropAllRoles()¶
On this page
Definition¶
-
db.dropAllRoles(writeConcern)¶ Deletes all user-defined roles on the database where you run the method.
Warning
The
dropAllRolesmethod removes all user-defined roles from the database.The
dropAllRolesmethod takes the following argument:Field Type Description writeConcerndocument Optional. The level of write concern for the removal operation. The writeConcerndocument takes the same fields as thegetLastErrorcommand.Returns: The number of user-defined roles dropped. The
db.dropAllRoles()method wraps thedropAllRolesFromDatabasecommand.
Behavior¶
Replica set¶
If run on a replica set, db.dropAllRoles() is executed using majority write concern by default.
Example¶
The following operations drop all user-defined roles from the products database and uses a
write concern of majority.
The method returns the number of roles dropped: