Skip to content
Merged
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
19 changes: 10 additions & 9 deletions source/reference/method/db.collection.update.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,28 @@ db.collection.update()
accepts parameters in a more clear :term:`document` form to
specify ``multi`` and ``upsert`` options.

The :method:`update() <db.collection.update()>` method provides the ability to
modify an existing document in a collection.
The :method:`update() <db.collection.update()>` method provides the
ability to modify an existing document in a collection.

By default the :method:`update() <db.collection.update()>` method updates a
single document. If you specify a ``multi`` update, the
:method:`update() <db.collection.update()>` method will update all
documents in the collection that match the query criteria. If you
specify ``upsert``, the :method:`update() <db.collection.update()>`
method will insert the document if no document matches the query
criteria, and preform a conventional update otherwise. The
operation has the following form:
criteria; otherwise, it will perform a conventional update.

Before version 2.2, in the :program:`mongo` shell, ``upsert`` and
``multi`` were positional boolean options and the operation has the
following form:

.. code-block:: javascript

db.collection.update(query, update, <upsert,> <multi>)

Before version 2.0, in the :program:`mongo` shell, ``upsert`` and
``multi`` were positional boolean options. Since version 2.2, the
:method:`update() <db.collection.update()>` method can *also* take an
``options`` :term:`document` as a parameter to specify the
``multi`` and the ``upsert`` options.
Since version 2.2, the :method:`update() <db.collection.update()>`
method can *also* take an ``options`` :term:`document` as a
parameter to specify the ``multi`` and the ``upsert`` options.

The :method:`update() <db.collection.update()>` method takes the following
parameters:
Expand Down