diff --git a/source/reference/method/db.addUser-param-2.2.yaml b/source/reference/method/db.addUser-param-2.2.yaml new file mode 100644 index 00000000000..035e3ecf78b --- /dev/null +++ b/source/reference/method/db.addUser-param-2.2.yaml @@ -0,0 +1,35 @@ +object: + name: db.addUser() + type: method +field: + optional: false + type: param +name: user +type: string +position: 1 +description: "The username." +--- +object: + name: db.addUser() + type: method +field: + optional: false + type: param +name: password +type: string +position: 2 +description: "The corresponding password." +--- +object: + name: db.addUser() + type: method +field: + optional: true + type: param +name: readOnly +type: boolean +position: 3 +description: | + Defaults to ``false``. Grants users a restricted privilege set that + only allows the user to read the this database. +... diff --git a/source/reference/method/db.addUser-param.yaml b/source/reference/method/db.addUser-param.yaml index c625080fddd..bbdcaf6fb74 100644 --- a/source/reference/method/db.addUser-param.yaml +++ b/source/reference/method/db.addUser-param.yaml @@ -1,33 +1,64 @@ object: - name: - type: + name: db.addUser() + type: method field: optional: false type: param -name: -type: +name: user +type: string position: 1 -description: "" +description: | + The name of the user who is given access to the database. --- object: - name: - type: + name: db.addUser() + type: method field: - optional: + optional: true type: param -name: -type: +name: pwd +type: hash position: 2 -description: "" +description: | + A shared secret used to authenticate the user. The ``pwd`` field and + the ``userSource`` field are mutually exclusive. The document cannot + contain both. --- object: - name: - type: + name: db.addUser() + type: method field: - optional: + optional: true type: param -name: -type: +name: roles +type: array position: 3 -description: "" +description: | + An array of user roles. +--- +object: + name: db.addUser() + type: method +field: + optional: true + type: param +name: userSource +type: string +position: 4 +description: | + The database that contains the credentials for the user. The + ``userSource`` field and the ``pwd`` field are mutually exclusive. + The document cannot contain both. +--- +object: + name: db.addUser() + type: method +field: + optional: true + type: param +name: otherDBRoles +type: document +position: 5 +description: | + Roles this user has on other databases. ... diff --git a/source/reference/method/db.addUser.txt b/source/reference/method/db.addUser.txt index 5ffe3bdd1ba..478d6830fce 100644 --- a/source/reference/method/db.addUser.txt +++ b/source/reference/method/db.addUser.txt @@ -4,6 +4,9 @@ db.addUser() .. default-domain:: mongodb +Definition +---------- + .. method:: db.addUser() Use :method:`db.addUser()` to add privilege documents to the @@ -23,92 +26,90 @@ db.addUser() to :method:`db.addUser()` that describe :ref:`user credentials `. - See :doc:`/reference/privilege-documents` for more information - about the form of the 2.4 privilege documents. - - Consider the following prototypes form for a :method:`db.addUser()` - operations: + The method contains a 2.4 privilege document with a subset of the + following fields. For detailed information about the form of the 2.4 + privilege documents, see :doc:`/reference/privilege-documents`. - .. code-block:: javascript + .. include:: /reference/method/db.addUser-param.rst - db.addUser( { user: "", pwd: "", roles: [] } ) +Examples +-------- - This operation creates a :data:`system.users - <.system.users>` document with a password using the - :data:`~.system.users.pwd` field +The following are prototype :method:`db.addUser()` operations: - In the following prototype, rather than specify a password - directly, you can delegated the credential to another database - using the :data:`~.system.users.userSource` field: +.. code-block:: javascript - .. code-block:: javascript + db.addUser( { user: "", pwd: "", roles: [] } ) - db.addUser( { user: "", userSource: "", roles: [] } ) +This operation creates a :data:`system.users +<.system.users>` document with a password using the +:data:`~.system.users.pwd` field - .. example:: +In the following prototype, rather than specify a password +directly, you can delegated the credential to another database +using the :data:`~.system.users.userSource` field: - To create and add a 2.4-style privilege document to - :data:`system.users <.system.users>` to grant - :authrole:`readWrite` privileges to a user named "author" with - privileges, use the following operation: +.. code-block:: javascript - .. code-block:: javascript + db.addUser( { user: "", userSource: "", roles: [] } ) - db.addUser( { user: "author", pwd: "pass", roles: [ "readWrite" ] } ) +To create and add a 2.4-style privilege document to +:data:`system.users <.system.users>` to grant +:authrole:`readWrite` privileges to a user named "author" with +privileges, use the following operation: - If you want to store user credentials in a single ``users`` - database, you can use :ref:`delegated credentials - `, as in the following example: +.. code-block:: javascript - .. code-block:: javascript + db.addUser( { user: "author", pwd: "pass", roles: [ "readWrite" ] } ) - db.addUser( { user: "author", userSource: "users", roles: [ "readWrite" ] } ) +If you want to store user credentials in a single ``users`` +database, you can use :ref:`delegated credentials +`, as in the following example: - .. seealso:: +.. code-block:: javascript - - :doc:`/tutorial/add-user-to-database` + db.addUser( { user: "author", userSource: "users", roles: [ "readWrite" ] } ) - - :doc:`/reference/user-privileges` + .. seealso:: - - :doc:`/reference/privilege-documents` +- :doc:`/tutorial/add-user-to-database` - .. _v2.2-style-addUser: +- :doc:`/reference/user-privileges` - To create legacy (2.2. and earlier) privilege documents, - :method:`db.addUser()` provides accepts the following parameters: +- :doc:`/reference/privilege-documents` - :param string user: Specifies the username. +Legacy Privilege Documents +-------------------------- - :param string password: Specifies the corresponding password. +.. _v2.2-style-addUser: - :param boolean readOnly: +To create legacy (2.2. and earlier) privilege documents, +:method:`db.addUser()` accepts the following parameters. - Optional. Defaults to ``false``. Grants users a restricted - privilege set that only allows the user to read the this - database. +.. include:: /reference/method/db.addUser-param-2.2.rst - Consider the following syntax: +The command takes the following form: - .. code-block:: javascript +.. code-block:: javascript - db.addUser( "", "", { readOnly: } ) + db.addUser( "", "", { readOnly: } ) - .. example:: +.. example:: - To create and add a legacy (2.2. and earlier) privilege - document with a user named ``guest`` and the password ``pass`` - that has only ``readOnly`` privileges, use the following - operation: + To create and add a legacy (2.2. and earlier) privilege document with + a user named ``guest`` and the password ``pass`` that has only + ``readOnly`` privileges, use the following operation: - .. code-block:: javascript + .. code-block:: javascript - db.addUser( "guest", "pass", { readOnly: true } ) + db.addUser( "guest", "pass", { readOnly: true } ) - .. note:: The :program:`mongo` shell excludes all - :method:`db.addUser()` operations from the saved history. +.. note:: The :program:`mongo` shell excludes all + :method:`db.addUser()` operations from the saved history. - .. deprecated:: 2.4 The ``roles`` parameter replaces the - ``readOnly`` parameter for :method:`db.addUser()`. 2.4 also adds - the :data:`~admin.system.users.otherDBRoles` and - :data:`~.system.users.userSource` fields to documents in the - :data:`system.users <.system.users>` collection. +.. deprecated:: 2.4 The ``roles`` parameter replaces the ``readOnly`` + parameter for :method:`db.addUser()`. 2.4 also adds the + :data:`~admin.system.users.otherDBRoles` and + :data:`~.system.users.userSource` fields to + documents in the :data:`system.users + <.system.users>` collection. diff --git a/source/reference/method/db.cloneCollection-param.yaml b/source/reference/method/db.cloneCollection-param.yaml index c625080fddd..00883e11721 100644 --- a/source/reference/method/db.cloneCollection-param.yaml +++ b/source/reference/method/db.cloneCollection-param.yaml @@ -1,33 +1,43 @@ object: - name: - type: + name: db.cloneCollection() + type: method field: optional: false type: param -name: -type: +name: from +type: string position: 1 -description: "" +description: | + Host name of the MongoDB instance that holds the collection to copy. --- object: - name: - type: + name: db.cloneCollection() + type: method field: - optional: + optional: false type: param -name: -type: +name: collection +type: string position: 2 -description: "" +description: | + The collection in the MongoDB instance that you want to copy. + :method:`db.cloneCollection()` will only copy the collection with this + name from *database* of the same name as the current database the + remote MongoDB instance. If you want to copy a collection from a + different database name you must use the :dbcommand:`cloneCollection` + directly. --- object: - name: - type: + name: db.cloneCollection() + type: method field: - optional: + optional: true type: param -name: -type: +name: query +type: document position: 3 -description: "" +description: | + A standard :ref:`MongoDB query document ` to + limit the documents copied as part of the + :method:`db.cloneCollection()` operation. ... diff --git a/source/reference/method/db.cloneCollection.txt b/source/reference/method/db.cloneCollection.txt index bc6d61e758b..2d3b4bf5d0a 100644 --- a/source/reference/method/db.cloneCollection.txt +++ b/source/reference/method/db.cloneCollection.txt @@ -4,29 +4,22 @@ db.cloneCollection() .. default-domain:: mongodb +Definition +---------- + .. method:: db.cloneCollection(from, collection, query) - :method:`db.cloneCollection()` provides a wrapper around - :dbcommand:`cloneCollection` for copying data directly between + Copies data directly between MongoDB instances. :method:`db.cloneCollection()` does not allow - you to clone a collection through a :program:`mongos`: you must + you to clone a collection through a :program:`mongos`. You must connect directly to the :program:`mongod` instance. - :param string from: A host name, of the MongoDB instance that holds - the collection you wish to copy - - :param string collection: A collection in the MongoDB instance that - you want to - copy. :method:`db.cloneCollection()` will - only copy the collection with this name - from *database* of the same name as the - current database the remote MongoDB - instance. If you want to copy a - collection from a different database name - you must use the - :dbcommand:`cloneCollection` directly. - - :param document query: Optional. A standard :ref:`MongoDB query - document ` to limit - the documents copied as part of the - :method:`db.cloneCollection()` operation. + The method contains the following fields: + + .. include:: /reference/method/db.cloneCollection-param.rst + + The :method:`db.cloneCollection()` method provides a wrapper around + :dbcommand:`cloneCollection`. + +.. Example +.. ------- diff --git a/source/reference/method/db.copyDatabase-param.yaml b/source/reference/method/db.copyDatabase-param.yaml index c625080fddd..9089fc1a1fe 100644 --- a/source/reference/method/db.copyDatabase-param.yaml +++ b/source/reference/method/db.copyDatabase-param.yaml @@ -1,33 +1,37 @@ object: - name: - type: + name: db.copyDatabase() + type: method field: optional: false type: param -name: -type: +name: origin +type: string position: 1 -description: "" +description: | + The name of the database on the origin system. --- object: - name: - type: + name: db.copyDatabase() + type: method field: - optional: + optional: false type: param -name: -type: +name: destination +type: string position: 2 -description: "" +description: | + The name of the database to copy the origin database into. --- object: - name: - type: + name: db.copyDatabase() + type: method field: - optional: + optional: true type: param -name: -type: +name: hostname +type: string position: 3 -description: "" +description: | + The hostname of the origin database host. Omit the hostname to copy + from one name to another on the same server. ... diff --git a/source/reference/method/db.copyDatabase.txt b/source/reference/method/db.copyDatabase.txt index d0cedbc196a..0a508d7fea7 100644 --- a/source/reference/method/db.copyDatabase.txt +++ b/source/reference/method/db.copyDatabase.txt @@ -4,36 +4,31 @@ db.copyDatabase() .. default-domain:: mongodb -.. method:: db.copyDatabase(origin, destination, hostname) - - :param database origin: Specifies the name of the database on the - origin system. - - :param database destination: Specifies the name of the database - that you wish to copy the origin - database into. +Definition +---------- - :param origin hostname: Indicate the hostname of the origin database - host. Omit the hostname to copy from one - name to another on the same server. +.. method:: db.copyDatabase(origin, destination, hostname) - Use this function to copy a specific database, named ``origin`` + Copies a specific database, named ``origin`` running on the system accessible via ``hostname`` into the local database named ``destination``. The command creates destination databases implicitly when they do not exist. If you omit the hostname, MongoDB will copy data from one database into another on the same instance. + .. include:: /reference/method/db.copyDatabase-param.rst + This function provides a wrapper around the MongoDB :term:`database - command` ":dbcommand:`copydb`." The :dbcommand:`clone` database + command` :dbcommand:`copydb`. The :dbcommand:`clone` database command provides related functionality. - .. example:: +Example +------- - Given a database named ``records`` that you want to copy into a - database named ``archive_records``, you could use the following - invocation of :method:`db.copyDatabase()`: +Given a database named ``records`` that you want to copy into a +database named ``archive_records``, you could use the following +invocation of :method:`db.copyDatabase()`: - .. code-block:: javascript +.. code-block:: javascript - db.copyDatabase('records', 'archive_records') + db.copyDatabase('records', 'archive_records')