w3resource

MongoDB: db.revokeRolesFromRole() method () method

db.revokeRolesFromRole()

The db.revokeRolesFromRole() method is used to remove inherited roles from a role.

Syntax:

db.revokeRolesFromRole( "<rolename>", [ <roles> ], { <writeConcern> } )

Parameters:

Name Description Required /
Optional
Type
rolename The name of the role from which to revoke roles. Required String
roles The inherited roles to remove. Required array
writeConcern The level of write concern to apply to this operation. The writeConcern document uses the same fields as the getLastError command. Optional document

In the roles field, you can specify both built-in roles and user-defined role.

To specify a role that exists in the same database where db.revokeRolesFromRole() runs, you can either specify the role with the name of the role:

"readWrite"

Or you can specify the role with a document, as in:

{ role: "<role>", db: "<database>" }

To specify a role that exists in a different database, specify the role with a document.

Retrieve the restaurants data from here

Required Access

You must have the grantRole action on a database to grant a role on that database.

Previous: db.grantPrivilegesToRole() method
Next: db.grantRolesToRole() method



Follow us on Facebook and Twitter for latest update.