Skip to content
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
22 changes: 22 additions & 0 deletions source/reference/command/applyOps-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
object:
name: applyOps
type: command
field:
optional: false
type: param
name: operations
type: array
position: 1
description: "An array of operations to perform."
---
object:
name: applyOps
type: command
field:
optional: true
type: param
name: preCondition
type: array
position: 2
description: "Defines one or more conditions that the destination must meet applying the entries from the ``<operations>`` array. Use ``ns`` to specify a :term:`namespace`, ``q`` to specify a :term:`query` and ``res`` to specify the result that the query should match. You may specify zero, one, or many ``preCondition`` documents."
...
32 changes: 16 additions & 16 deletions source/reference/command/applyOps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,29 @@ applyOps

.. default-domain:: mongodb

.. dbcommand:: applyOps

:param array operations: an array of operations to perform.
Definition
----------

:param array preCondition: Optional. Defines one or more conditions that the destination must meet
applying the entries from the ``<operations>`` array.
Use ``ns`` to
specify a :term:`namespace`, ``q`` to specify a :term:`query` and
``res`` to specify the result that the query should match. You may
specify zero, one, or many ``preCondition`` documents.
.. dbcommand:: applyOps

:dbcommand:`applyOps` provides a way to apply entries from an
Provides a way to apply entries from an
:term:`oplog` created by :term:`replica set` members and
:term:`master` instances in a master/:term:`slave`
deployment. :dbcommand:`applyOps` is primarily an internal command
to support sharding functionality, and has the following prototype
form:
to support sharding functionality.

.. include:: /reference/command/applyOps-param.rst

:dbcommand:`applyOps` has the following prototype form:

.. code-block:: javascript

db.runCommand( { applyOps: [ <operations> ], preCondition: [ { ns: <namespace>, q: <query>, res: <result> } ] } )

:dbcommand:`applyOps` applies oplog entries from the
``<operations>`` array, to the :program:`mongod` instance. The
``preCondition`` array provides the ability to specify conditions
that must be true in order to apply the oplog entry.
:dbcommand:`applyOps` applies oplog entries from the ``<operations>``
array, to the :program:`mongod` instance. The ``preCondition`` array
provides the ability to specify conditions that must be true in order
to apply the oplog entry.

You can specify as many ``preCondition`` sets as needed. If you
specify the ``ns`` option, :dbcommand:`applyOps` will only apply
Expand All @@ -43,3 +40,6 @@ applyOps
.. write-lock

.. see: DOCS-133; SERVER-4259

.. Example
.. -------
22 changes: 22 additions & 0 deletions source/reference/command/sleep-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
object:
name: sleep
type: command
field:
optional: false
type: param
name: w
type: boolean
position: 1
description: "If true, obtains a global write lock. Otherwise obtains a read lock."
---
object:
name: sleep
type: command
field:
optional: false
type: param
name: secs
type: integer
position: 2
description: "Specifies the number of seconds to sleep."
...
23 changes: 14 additions & 9 deletions source/reference/command/sleep.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@ sleep

.. default-domain:: mongodb

Definition
----------

.. dbcommand:: sleep

:dbcommand:`sleep` is an internal command for testing purposes. The
:dbcommand:`sleep` command forces the database to block all operations. It
takes the following options:

:param boolean w: If true, obtain a global write lock. Otherwise
obtains a read lock.
:param integer secs: Specifies the number of seconds to sleep.
Internal command for testing purposes. The :dbcommand:`sleep` command
forces the database to block all operations.

.. include:: /reference/command/sleep-param.rst

The :dbcommand:`sleep` command takes the following prototype form:

.. code-block:: javascript

{ sleep: { w: true, secs: <seconds> } }

The above command places the :program:`mongod` instance in a
"write-lock" state for a specified (i.e. ``<seconds>``) number of
seconds. Without arguments, :dbcommand:`sleep`, causes a "read
lock" for 100 seconds.
seconds. Without arguments, :dbcommand:`sleep`, causes a "read lock"
for 100 seconds.

.. warning::

Expand All @@ -33,3 +35,6 @@ sleep

.. |dbcommand| replace:: :dbcommand:`sleep`
.. include:: /includes/note-enabletestcommands.rst

.. Example
.. -------
27 changes: 27 additions & 0 deletions source/reference/method/Mongo.setReadPref-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
object:
name: Mongo.setReadPref()
type: method
field:
optional: false
type: param
name: mode
type: string
position: 1
description: "One of the following read preference modes:
- :readmode:`primary`
- :readmode:`primaryPreferred`
- :readmode:`secondary`
- :readmode:`secondaryPreferred`
- :readmode:`nearest`"
---
object:
name: Mongo.setReadPref()
type: method
field:
optional: true
type: param
name: tagSet
type: array
position: 2
description: "A tag set. See :ref:`tag sets <replica-set-read-preference-tag-sets>` for information on using tag sets to provide custom read preference modes."
...
100 changes: 46 additions & 54 deletions source/reference/method/Mongo.setReadPref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,55 @@ Mongo.setReadPref()

.. default-domain:: mongodb

.. method:: Mongo.setReadPref(<mode>, <tagSet>)
Definition
----------

:param string mode: Read preference mode.

:param array tagSet: Optional. A tag set .
.. method:: Mongo.setReadPref(mode, tagSet)

Call the :method:`~Mongo.setReadPref()` method on a :method:`Mongo
<db.getMongo()>` connection object to control how the client will
route all queries to members of the replica set.

The ``mode`` string should be one of:

- :readmode:`primary`
- :readmode:`primaryPreferred`
- :readmode:`secondary`
- :readmode:`secondaryPreferred`
- :readmode:`nearest`

See the :ref:`tag sets <replica-set-read-preference-tag-sets>`
documentation for more information on using tag sets to provide
custom read preference modes.

To set a read preference mode in the :program:`mongo` shell, use
the following operation:

.. code-block:: javascript

db.getMongo().setReadPref('primaryPreferred')

To set a read preference that uses a tag set, specify an array of
tag sets as the second argument to :method:`Mongo.setReadPref()`,
as in the following:

.. code-block:: javascript

db.getMongo().setReadPref('primaryPreferred', [ { "dc": "east" } ] )

You can specify multiple tag sets, in order of preference, as in
the following:

.. code-block:: javascript

db.getMongo().setReadPref('secondaryPreferred',
[ { "dc": "east", "use": "production" },
{ "dc": "east", "use": "reporting" },
{ "dc": "east" },
{}
] )

If the replica set cannot satisfy the first tag set, the client
will attempt to use the second read preference. Each tag set can
contain zero or more field/value tag pairs, with an "empty"
document acting as a wildcard which matches a replica set member
with any tag set or no tag set.

.. note::

You must call :method:`Mongo.setReadPref()` on the connection
object before retrieving documents using that connection to use
that read preference.
.. include:: /reference/method/Mongo.setReadPref-param.rst

Examples
--------

To set a read preference mode in the :program:`mongo` shell, use the
following operation:

.. code-block:: javascript

db.getMongo().setReadPref('primaryPreferred')

To set a read preference that uses a tag set, specify an array of tag
sets as the second argument to :method:`Mongo.setReadPref()`, as in the
following:

.. code-block:: javascript

db.getMongo().setReadPref('primaryPreferred', [ { "dc": "east" } ] )

You can specify multiple tag sets, in order of preference, as in the
following:

.. code-block:: javascript

db.getMongo().setReadPref('secondaryPreferred',
[ { "dc": "east", "use": "production" },
{ "dc": "east", "use": "reporting" },
{ "dc": "east" },
{}
] )

If the replica set cannot satisfy the first tag set, the client will
attempt to use the second read preference. Each tag set can contain zero
or more field/value tag pairs, with an "empty" document acting as a
wildcard which matches a replica set member with any tag set or no tag
set.

.. note::

You must call :method:`Mongo.setReadPref()` on the connection object
before retrieving documents using that connection to use that read
preference.
27 changes: 27 additions & 0 deletions source/reference/method/cursor.readPref-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
object:
name: cursor.readPref()
type: method
field:
optional: false
type: param
name: mode
type: string
position: 1
description: "The read preference mode. Use one of the following:
- :readmode:`primary`
- :readmode:`primaryPreferred`
- :readmode:`secondary`
- :readmode:`secondaryPreferred`
- :readmode:`nearest`"
---
object:
name: cursor.readPref()
type: method
field:
optional: true
type: param
name: tagSet
type: array of tag set objects
position: 2
description: "See the :ref:`tag sets <replica-set-read-preference-tag-sets>` documentation for more information on using tag sets to provide custom read preference modes."
...
25 changes: 9 additions & 16 deletions source/reference/method/cursor.readPref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,21 @@ cursor.readPref()

.. default-domain:: mongodb

.. method:: cursor.readPref()
Definition
----------

:param string mode: Read preference mode.
:param array tagSet: Optional. Array of tag set objects.
.. method:: cursor.readPref(mode, tagSet)

Append the :method:`readPref() <cursor.readPref()>` to a cursor to
control how the client will route the query will route to members
Append :method:`readPref() <cursor.readPref()>` to a cursor to
control how the client routes the query to members
of the replica set.

The ``mode`` string should be one of:

- :readmode:`primary`
- :readmode:`primaryPreferred`
- :readmode:`secondary`
- :readmode:`secondaryPreferred`
- :readmode:`nearest`

See the :ref:`tag sets <replica-set-read-preference-tag-sets>`
documentation for more information on using tag sets to provide
custom read preference modes.
.. include:: /reference/method/cursor.readPref-param.rst

.. note::

You must apply :method:`cursor.readPref()` to the cursor before retrieving
any documents from the database.

.. Example
.. -------
22 changes: 22 additions & 0 deletions source/reference/method/db.auth-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
object:
name: db.auth()
type: method
field:
optional: false
type: param
name: username
type: string
position: 1
description: "Specifies an existing username with access privileges for this database."
---
object:
name: db.auth()
type: method
field:
optional: false
type: param
name: password
type: string
position: 2
description: "Specifies the corresponding password."
...
15 changes: 10 additions & 5 deletions source/reference/method/db.auth.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ db.auth()

.. default-domain:: mongodb

Definition
----------

.. method:: db.auth("username", "password")

:param string username: Specifies an existing username with access
privileges for this database.
Allows a user to authenticate to the database from within the
shell.

:param string password: Specifies the corresponding password.
.. include:: /reference/method/db.auth-param.rst

Allows a user to authenticate to the database from within the
shell. Alternatively use :option:`mongo --username` and
Alternatively, you can use :option:`mongo --username` and
:option:`--password <mongo --password>` to specify authentication
credentials.

.. |operation-name| replace:: :method:`db.auth()`
.. include:: /includes/note-auth-methods-excluded-from-shell-history.rst

.. Example
.. -------
Loading