From e78a84f01aab201a834cdf543f616721b6e7524d Mon Sep 17 00:00:00 2001 From: kay Date: Thu, 1 Nov 2012 13:17:08 -0400 Subject: [PATCH] DOCS-617 add to delete doc --- draft/applications/delete.txt | 26 +++++++++++++++++++ ...t-remove-capped-collection-restriction.rst | 2 ++ .../reference/method/db.collection.remove.txt | 21 ++++++++++++++- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 source/includes/fact-remove-capped-collection-restriction.rst diff --git a/draft/applications/delete.txt b/draft/applications/delete.txt index 98992a7f2f1..2aaf2e02477 100644 --- a/draft/applications/delete.txt +++ b/draft/applications/delete.txt @@ -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() +` 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 } ) + + \ No newline at end of file diff --git a/source/includes/fact-remove-capped-collection-restriction.rst b/source/includes/fact-remove-capped-collection-restriction.rst new file mode 100644 index 00000000000..ef3f38038e4 --- /dev/null +++ b/source/includes/fact-remove-capped-collection-restriction.rst @@ -0,0 +1,2 @@ +You cannot apply the :method:`remove() ` method +to a :term:`capped collection`. diff --git a/source/reference/method/db.collection.remove.txt b/source/reference/method/db.collection.remove.txt index de684d837d8..d446067ac0d 100644 --- a/source/reference/method/db.collection.remove.txt +++ b/source/reference/method/db.collection.remove.txt @@ -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 @@ -54,7 +57,7 @@ db.collection.remove() - To remove the first document that match a deletion criteria, call the :method:`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 @@ -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() + ` 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 } )