Skip to content

DOCS-2247 add dropAllUsers method #1413

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
8 changes: 8 additions & 0 deletions bin/builddata/htaccess.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3275,4 +3275,12 @@ code: 301
outputs:
- 'master'
- 'manual'
---
redirect-path: '/reference/method/db.dropAllUsers'
url-base: '/reference/security'
type: 'redirect'
code: 301
outputs:
- 'manual'
- 'before-v2.4'
...
3 changes: 3 additions & 0 deletions source/includes/access-drop-all-users.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
To issue the :dbcommand:`dropAllUsersFromDatabase` command, a user must
have access that includes the :authaction:`dropUser` action for that
database.
10 changes: 5 additions & 5 deletions source/includes/ref-toc-method-user-management.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ description: |
# description: |
# Removes a single user.
# ---
# name: :method:`db.dropAllUsers()`
# file: /reference/method/db.dropAllUsers
# description: |
# Deletes all users associated with a database.
# ---
name: :method:`db.dropAllUsers()`
file: /reference/method/db.dropAllUsers
description: |
Deletes all users associated with a database.
---
# name: :method:`db.grantRolesToUser()`
# file: /reference/method/db.grantRolesToUser
# description: |
Expand Down
7 changes: 3 additions & 4 deletions source/reference/command/dropAllUsersFromDatabase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ Definition
Required Access
---------------

To issue the :dbcommand:`dropAllUsersFromDatabase` command, a user must
have access that includes the :authaction:`dropUser` action for that
database.
.. include:: /includes/access-drop-all-users.rst

Example
-------
Expand All @@ -45,7 +43,8 @@ every user from the ``products`` database:

.. code-block:: javascript

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

The ``n`` field in the results document shows the number of users
removed:
Expand Down
4 changes: 4 additions & 0 deletions source/reference/method/db.dropAllUsers-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
file: /reference/command/dropUser-field.yaml
name: writeConcern
position: 1
...
48 changes: 48 additions & 0 deletions source/reference/method/db.dropAllUsers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
=================
db.dropAllUsers()
=================

.. default-domain:: mongodb

Definition
----------

.. method:: db.dropAllUsers ( writeConcern )

Removes all users from the database on which you run the command.

.. warning::

The :method:`dropAllUsers` method removes all users from the database.

The :method:`dropAllUsers` method takes the following arguments:

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

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

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

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

.. include:: /includes/access-drop-all-users.rst

Example
-------

The following :method:`db.dropAllUsers()` operation drops every user from
the ``products`` database.

.. code-block:: javascript

use products
db.dropAllUsers( {w: "majority", wtimeout: 5000} )

The ``n`` field in the results document shows the number of users
removed:

.. code-block:: javascript

{ "n" : 12, "ok" : 1 }