Skip to content

DOCS-617 add to delete doc #363

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

Merged
merged 1 commit into from
Nov 1, 2012
Merged
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
26 changes: 26 additions & 0 deletions draft/applications/delete.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,30 @@ Consider the following examples that illustrate the usage of the
.. code-block:: javascript

db.csbios.remove()

.. _crud-delete-remove-isolation:

Capped Collection
~~~~~~~~~~~~~~~~~

.. include:: /includes/fact-remove-capped-collection-restriction.rst

Isolation
~~~~~~~~~

If the ``query`` argument to the :method:`remove()
<db.collection.remove()>` method matches multiple documents in the
collection, the delete operation may interleave with other write
operations to that collection. For an unsharded collection, you have
the option to override this behavior with the :operator:`$atomic`
isolation operator, effectively isolating the delete operation and
blocking all other operations during the delete. To isolate the query,
include ``$atomic: 1`` in the ``query`` parameter as in the following
example:

.. code-block:: javascript

db.csbios.remove( { turing: true, $atomic: 1 } )



2 changes: 2 additions & 0 deletions source/includes/fact-remove-capped-collection-restriction.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
You cannot apply the :method:`remove() <db.collection.remove()>` method
to a :term:`capped collection`.
21 changes: 20 additions & 1 deletion source/reference/method/db.collection.remove.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ db.collection.remove()
document. The default value is ``false``. Set to ``true`` to
delete only the first result.

.. note::
.. include:: /includes/fact-remove-capped-collection-restriction.rst

.. examples-begin

Consider the following examples of the :method:`remove
Expand Down Expand Up @@ -54,7 +57,7 @@ db.collection.remove()

- To remove the first document that match a deletion criteria, call the
:method:`remove <db.collection.remove()>` method with the ``query``
criteria and the ``justOne`` parameter set to ``true``:
criteria and the ``justOne`` parameter set to ``true`` or ``1``:

.. code-block:: javascript

Expand All @@ -64,3 +67,19 @@ db.collection.remove()
``products`` where ``qty`` is greater than ``20``.

.. examples-end

.. note::

If the ``query`` argument to the :method:`remove()
<db.collection.remove()>` method matches multiple documents in
the collection, the delete operation may interleave with other
write operations to that collection. For an unsharded collection,
you have the option to override this behavior with the
:operator:`$atomic` isolation operator, effectively isolating the
delete operation and blocking all other operations during the
delete. To isolate the query, include ``$atomic: 1`` in the
``query`` parameter as in the following example:

.. code-block:: javascript

db.products.remove( { qty: { $gt: 20 }, $atomic: 1 } )