Skip to content

DOCS-6982: clarify result of upsert #2529

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

Closed
wants to merge 1 commit into from
Closed
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
37 changes: 28 additions & 9 deletions source/includes/steps-getting-started-update-upsert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,35 @@ action:
"nModified" : 0,
"_id" : ObjectId("53dbd7c8babeaec6342ed6c8")
})
post: |
The :data:`~WriteResult.nMatched` field shows that the operation
matched ``0`` documents.
- pre: |
The :data:`~WriteResult.nMatched` field shows that the operation
matched ``0`` documents.

The :data:`~WriteResult.nUpserted` of ``1`` shows that the update
added a document.
The :data:`~WriteResult.nUpserted` of ``1`` shows that the update
added a document.

The :data:`~WriteResult.nModified` of ``0`` specifies that no
existing documents were updated.
The :data:`~WriteResult.nModified` of ``0`` specifies that no
existing documents were updated.

The ``_id`` field shows the generated ``_id`` field for the added
document.
The information above indicates that the operation has created one
new document. The ``_id`` field shows the generated ``_id`` field
for the added document; you can perform a query to confirm the
result:
language: javascript
code: |
db.inventory.findOne( { _id: ObjectId("53dbd7c8babeaec6342ed6c8") } )
- pre: |
The result matches the document specified in the
:method:`~db.collection.update()`:
language: javascript
code: |
{
"_id" : ObjectId("56a12ec8242ae5d73c07b15e"),
"item" : "TBD2",
"details" : {
"model" : "14Q3",
"manufacturer" : "IJK Co."
},
"category" : "houseware"
}
...