MongoDB: db.dropAllRoles() method
db.dropAllRoles()
The db.dropAllRoles() method is used to delete all user-defined roles associated with a database.
Syntax:
db.dropAllRoles(writeConcern)
Note:
The dropAllRoles method removes all user-defined roles from the database.
Parameters:
Name | Description | Required / Optional |
Type |
---|---|---|---|
writeConcern | The level of write concern for the removal operation. The writeConcern document takes the same fields as the getLastError command. | Optional | document |
Example: MongoDB: db.dropAllRoles() method
The following operations drop all user-defined roles from the test database and uses a write concern of majority.
use test
db.dropAllRoles( { w: "majority" } );
Retrieve the restaurants data from here
Required Access
You must have the dropRole action on a database to drop a role from that database.
Previous:
db.dropRole() method
Next:
db.grantPrivilegesToRole() method
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/mongodb/shell-methods/role-management/db-dropAllRoles.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics