w3resource

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



Follow us on Facebook and Twitter for latest update.