Skip to content

Commit 7c1e372

Browse files
authored
DOCSP-36124 Adds upsertedCount to updateOne and updateMany (#6152) (#6231)
* DOCSP-36124 Adds upsertedCount to updateOne and updateMany * Adds upsertedCount to examples
1 parent 32a2fef commit 7c1e372

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

source/reference/method/db.collection.updateMany.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ The method returns a document that contains:
181181

182182
- ``upsertedId`` containing the ``_id`` for the upserted document
183183

184+
- ``upsertedCount`` containing the number of upserted documents
185+
184186
Access Control
185187
--------------
186188

@@ -585,7 +587,8 @@ The operation returns:
585587
"acknowledged" : true,
586588
"matchedCount" : 0,
587589
"modifiedCount" : 0,
588-
"upsertedId" : ObjectId("56fc5dcb39ee682bdc609b02")
590+
"upsertedId" : ObjectId("56fc5dcb39ee682bdc609b02"),
591+
"upsertedCount": 1
589592
}
590593

591594
The collection now contains the following documents:

source/reference/method/db.collection.updateOne.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ The method returns a document that contains:
178178

179179
- ``modifiedCount`` containing the number of modified documents
180180

181-
- ``upsertedId`` containing the ``_id`` for the upserted document.
181+
- ``upsertedId`` containing the ``_id`` for the upserted document
182+
183+
- ``upsertedCount`` containing the number of upserted documents
182184

183185
- A boolean ``acknowledged`` as ``true`` if the operation ran with
184186
:term:`write concern` or ``false`` if write concern was disabled
@@ -657,7 +659,8 @@ Since ``upsert:true`` the document is ``inserted`` based on the ``filter`` and
657659
"acknowledged" : true,
658660
"matchedCount" : 0,
659661
"modifiedCount" : 0,
660-
"upsertedId" : 4
662+
"upsertedId" : 4,
663+
"upsertedCount": 1
661664
}
662665

663666
The collection now contains the following documents:

0 commit comments

Comments
 (0)