dropAllRolesFromDatabase

Definition

  • dropAllRolesFromDatabase
  • Deletes all user-defined roleson the database where you run the command.

Warning

The dropAllRolesFromDatabase removes alluser-defined roles from the database.

The dropAllRolesFromDatabase command takes the followingform:

  1. {
  2. dropAllRolesFromDatabase: 1,
  3. writeConcern: { <write concern> }
  4. }

The command has the following fields:

FieldTypeDescriptiondropAllRolesFromDatabaseintegerSpecify 1 to drop all user-definedroles from the database where the command is run.writeConcerndocumentOptional. The level of write concern for theremoval operation. The writeConcern document takes the samefields as the getLastError command.

Required Access

You must have the dropRoleaction on a database to drop a role from that database.

Example

The following operations drop all user-defined roles from the products database:

  1. use products
  2. db.runCommand(
  3. {
  4. dropAllRolesFromDatabase: 1,
  5. writeConcern: { w: "majority" }
  6. }
  7. )

The n field in the results document reports the number of rolesdropped:

  1. { "n" : 4, "ok" : 1 }