Skip to content

DOCS-2247 add dropRole and dropRoles methods #1434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions bin/builddata/htaccess-next.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,22 @@ redirect-path: '/reference/method/db.getUsers'
url-base: '/reference/security'
type: 'redirect'
code: 303
outputs:
- 'manual'
- 'before-v2.4'
---
redirect-path: '/reference/method/db.dropRole'
url-base: '/reference/security'
type: 'redirect'
code: 303
outputs:
- 'manual'
- 'before-v2.4'
---
redirect-path: '/reference/method/db.dropAllRoles'
url-base: '/reference/security'
type: 'redirect'
code: 303
outputs:
- 'manual'
- 'before-v2.4'
Expand Down
2 changes: 2 additions & 0 deletions source/includes/access-drop-role.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
A user must have the :authaction:`dropRole` :ref:`action
<security-user-actions>` on a database to drop a role from that database.
20 changes: 10 additions & 10 deletions source/includes/ref-toc-method-role-management.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
# description: |
# Updates a user-defined role.
# ---
# name: :method:`db.dropRole()`
# file: /reference/method/db.dropRole
# description: |
# Deletes a user-defined role.
# ---
# name: :method:`db.dropAllRoles()`
# file: /reference/method/db.dropAllRoles
# description: |
# Deletes all user-defined roles associated with a database.
# ---
name: :method:`db.dropRole()`
file: /reference/method/db.dropRole
description: |
Deletes a user-defined role.
---
name: :method:`db.dropAllRoles()`
file: /reference/method/db.dropAllRoles
description: |
Deletes all user-defined roles associated with a database.
---
# name: :method:`db.grantPrivilegesToRole()`
# file: /reference/method/db.grantPrivilegesToRole
# description: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#content from this page is included in /reference/method/db.dropAllRoles-param.yaml
object:
name: dropAllRolesFromDatabase
type: dbcommand
Expand Down
20 changes: 13 additions & 7 deletions source/reference/command/dropAllRolesFromDatabase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ Definition

.. dbcommand:: dropAllRolesFromDatabase

Deletes all :ref:`user-defined <user-defined-roles>` roles defined
Deletes all :ref:`user-defined <user-defined-roles>` roles
on the database where you run the command.

.. warning::

The :dbcommand:`dropAllRolesFromDatabase` removes all
The :dbcommand:`dropAllRolesFromDatabase` removes *all*
:ref:`user-defined <user-defined-roles>` roles from the database.

The :dbcommand:`dropAllRolesFromDatabase` command takes the following
form:

.. code-block:: javascript

{ dropAllRolesFromDatabase: 1,
{
dropAllRolesFromDatabase: 1,
writeConcern: { <write concern> }
}

Expand All @@ -33,18 +34,23 @@ Definition
Required Access
---------------

To run :dbcommand:`dropAllRolesFromDatabase`, a user must have access that
includes the :authaction:`dropRole` action for the database.
.. include:: /includes/access-drop-role.rst

Example
-------

The following sequence of commands in the :program:`mongo` shell drops
The following operations drop
every role from the ``products`` database:

.. code-block:: javascript

db.getSiblingDB("products").runCommand( { dropAllRolesFromDatabase: 1, writeConcern: { w: "majority" } } )
use products
db.runCommand(
{
dropAllRolesFromDatabase: 1,
writeConcern: { w: "majority" }
}
)

The ``n`` field in the results document reports the number of roles
dropped:
Expand Down
4 changes: 3 additions & 1 deletion source/reference/command/dropRole-field.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#content from this page is included in /reference/method/db.dropRole-param.yaml
object:
name: dropRole
type: dbcommand
Expand All @@ -8,7 +9,8 @@ name: dropRole
type: string
position: 1
description: |
The name of the ref:`user-defined role <user-defined-roles>` to remove.
The name of the ref:`user-defined role <user-defined-roles>` to remove
from the database.
---
object:
name: dropRole
Expand Down
20 changes: 12 additions & 8 deletions source/reference/command/dropRole.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Definition

.. dbcommand:: dropRole

Deletes the user-defined role from the database on which you run the
command.
Deletes the :ref:`user-defined <user-defined-roles>` role from the
database on which you run the command.

The :dbcommand:`dropRole` command uses the following syntax:

Expand All @@ -21,23 +21,27 @@ Definition
writeConcern: { <write concern> }
}

The :dbcommand:`dropRole` document has the following fields:
The :dbcommand:`dropRole` command has the following fields:

.. include:: /reference/command/dropRole-field.rst

Required Access
---------------

To run :dbcommand:`dropRole`, a user must have access that includes the
:authaction:`dropRole` action on the database.
.. include:: /includes/access-drop-role.rst

Example
-------

The following command in the :program:`mongo` shell removes
the ``readPrices`` role from the ``products`` database:
The following operations remove the ``readPrices`` role from the
``products`` database:

.. code-block:: javascript

use products
db.getSiblingDB("products").runCommand( { dropRole: "readPrices", writeConcern: { w: "majority" } } )
db.runCommand(
{
dropRole: "readPrices",
writeConcern: { w: "majority" }
}
)
4 changes: 4 additions & 0 deletions source/reference/method/db.dropAllRoles-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
file: /reference/command/dropAllRolesFromDatabase-field.yaml
name: writeConcern
position: 1
...
50 changes: 50 additions & 0 deletions source/reference/method/db.dropAllRoles.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
=================
db.dropAllRoles()
=================

.. default-domain:: mongodb

Definition
----------

.. method:: db.dropAllRoles( writeConcern )

Deletes all :ref:`user-defined <user-defined-roles>` roles on the
database where you run the method.

.. warning::

The :method:`dropAllRoles` method removes *all* :ref:`user-defined
<user-defined-roles>` roles from the database.

The :method:`dropAllRoles` method takes the following argument:

.. include:: /reference/method/db.dropAllRoles-param.rst

The :method:`db.dropAllRoles()` method wraps the
:dbcommand:`dropAllRolesFromDatabase` command.

.. |local-cmd-name| replace:: :method:`db.dropAllRoles()`

Required Access
---------------

.. include:: /includes/access-drop-role.rst

Example
-------

The following operations drop every role from the ``products`` database and
uses a :ref:`write concern <write-concern-operation>` of ``majority``.

.. code-block:: javascript

use products
db.dropAllRoles( { w: "majority" } )

The ``n`` field in the results document reports the number of roles
dropped:

.. code-block:: javascript

{ "n" : 4, "ok" : 1 }
17 changes: 17 additions & 0 deletions source/reference/method/db.dropRole-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
object:
name: db.dropRole()
type: method
field:
optional: false
type: param
name: rolename
type: string
position: 1
description: |
The name of the ref:`user-defined role <user-defined-roles>` to remove
from the database.
---
file: /reference/command/dropRole-field.yaml
name: writeConcern
position: 2
...
38 changes: 38 additions & 0 deletions source/reference/method/db.dropRole.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
=============
db.dropRole()
=============

.. default-domain:: mongodb

Definition
----------

.. method:: db.dropRole( rolename, writeConcern )

Deletes the :ref:`user-defined <user-defined-roles>` role from the
database on which you run the method.

The :method:`db.dropRole()` method takes the following arguments:

.. include:: /reference/method/db.dropRole-param.rst

The :method:`db.dropRole()` method wraps the :dbcommand:`dropRole`
command.

.. |local-cmd-name| replace:: :method:`db.dropRole()`

Required Access
---------------

.. include:: /includes/access-drop-role.rst

Example
-------

The following operations remove the ``readPrices`` role from the
``products`` database:

.. code-block:: javascript

use products
db.dropRole( "readPrices", { w: "majority" } )