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
10 changes: 5 additions & 5 deletions source/reference/method/db.collection.findOneAndUpdate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ and increments the score by ``5``:

.. code-block:: javascript

db.scores.findOneAndUpdate(
db.grades.findOneAndUpdate(
{ "name" : "R. Stiles" },
{ $inc: { "points" : 5 } }
)
Expand Down Expand Up @@ -153,7 +153,7 @@ matching document with the least points.

.. code-block:: javascript

db.scores.findOneAndUpdate(
db.grades.findOneAndUpdate(
{ "name" : "A. MacDyver" },
{ $inc : { "points" : 5 } },
{ sort : { "points" : 1 } }
Expand All @@ -175,7 +175,7 @@ The following operation uses projection to only display the ``_id``,

.. code-block:: javascript

db.scores.findOneAndUpdate(
db.grades.findOneAndUpdate(
{ "name" : "A. MacDyver" },
{ $inc : { "points" : 5 } },
{ sort : { "points" : 1 }, projection: { "assignment" : 1, "points" : 1 } }
Expand All @@ -199,7 +199,7 @@ The following operation sets a 5ms time limit to complete the update:
.. code-block:: javascript

try {
db.scores.findOneAndUpdate(
db.grades.findOneAndUpdate(
{ "name" : "A. MacDyver" },
{ $inc : { "points" : 5 } },
{ sort: { "points" : 1 }, maxTimeMS : 5 };
Expand Down Expand Up @@ -227,7 +227,7 @@ document if nothing matches the ``filter``:
.. code-block:: javascript

try {
db.scores.findOneAndUpdate(
db.grades.findOneAndUpdate(
{ "name" : "A.B. Abracus" },
{ $set: { "name" : "A.B. Abracus", "assignment" : 5}, $inc : { "points" : 5 } },
{ sort: { "points" : 1 }, upsert:true, returnNewDocument : true }
Expand Down