Skip to content

Commit 3ef1e99

Browse files
author
Sam Kleinman
committed
DOCS-133 apply ops revision and clarification
1 parent ddef03a commit 3ef1e99

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

source/reference/commands.txt

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,26 +2466,42 @@ Internal Use
24662466

24672467
.. write-lock, slave-ok
24682468

2469-
.. dbcommand:: applyOps(operations, preCondition:[ ns: namespace, q: query, res: result ])
2469+
.. dbcommand:: applyOps
24702470

24712471
:param array operations: an array of operations to perform.
2472-
:param preCondition: Optional. Specifies a precondition which must be met before applying
2473-
the entry from the :term:`oplog`. Use :code:`ns` to specify a :term:`namespace`,
2474-
:code:`q` to specify a :term:`query` and :code:`res` to specify the
2475-
result which the query should match.
24762472

2477-
:dbcommand:`applyOps` is an internal command that supports sharding
2478-
functionality.
2479-
It applies :term:`oplog` entries passed to the command in the <operations> array, to a database, or collection if you specify the :term:`ns` option.
2473+
:param array preCondition: Optional. Defines one or more conditions that the destination must meet
2474+
applying the entries from the ``<operations>`` array. ``ns`` to
2475+
specify a :term:`namespace`, ``q`` to specify a :term:`query` and
2476+
``res`` to specify the result that the query should match. You may
2477+
specify, zero, one, or many ``preCondition`` documents.
2478+
2479+
:dbcommand:`applyOps` provides a way to apply entries from an
2480+
:term:`oplog` created by :term:`replica set` members and
2481+
:term:`master` instances in a master/:term:`slave`
2482+
deployment. :dbcommand:`applyOps` is primarily an internal command
2483+
to support sharding functionality, and has the following prototype
2484+
form:
24802485

2481-
.. code-block:: javascript
2486+
.. code-block:: javascript
2487+
2488+
db.runCommand( { applyOps: [ <operations> ], preCondition: [ { ns: <namespace>, q: <query>, res: <result> } ] } )
24822489

2483-
db.runCommand({ { applyOps: <operations>, preCondition: [ ns: <namespace>, q: <query>, res: <result> ] } )
2490+
:dbcommand:`applyOps` applies oplog entries from the
2491+
``<operations>`` array, to the :program:`mongod` instance. The
2492+
``preCondition`` array provides the ability to specify conditions
2493+
that must be true in order to apply the oplog entry.
24842494

2495+
You can specify as many ``preCondition`` sets as needed. If you
2496+
specify the ``ns`` option, :dbcommand:`applyOps` will only apply
2497+
oplog entries for the :term:`collection` described by that
2498+
namespace. You may also specify a query in the ``q`` field with a
2499+
corresponding expected result in the ``res`` field that must match
2500+
in order to apply the oplog entry.
24852501

2486-
.. write-lock
2502+
.. write-lock
24872503

2488-
.. see: DOCS-133; SERVER-4259
2504+
.. see: DOCS-133; SERVER-4259
24892505

24902506
.. dbcommand:: replSetElect
24912507

0 commit comments

Comments
 (0)