Skip to content

Commit fe9ce97

Browse files
authored
DOCSP-36124 Adds upsertedCount to updateOne and updateMany (#6152) (#6233)
* DOCSP-36124 Adds upsertedCount to updateOne and updateMany * Adds upsertedCount to examples
1 parent c0c8065 commit fe9ce97

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
@@ -183,6 +183,8 @@ The method returns a document that contains:
183183

184184
- ``upsertedId`` containing the ``_id`` for the upserted document
185185

186+
- ``upsertedCount`` containing the number of upserted documents
187+
186188
Access Control
187189
--------------
188190

@@ -584,7 +586,8 @@ The operation returns:
584586
"acknowledged" : true,
585587
"matchedCount" : 0,
586588
"modifiedCount" : 0,
587-
"upsertedId" : ObjectId("56fc5dcb39ee682bdc609b02")
589+
"upsertedId" : ObjectId("56fc5dcb39ee682bdc609b02"),
590+
"upsertedCount": 1
588591
}
589592

590593
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
@@ -180,7 +180,9 @@ The method returns a document that contains:
180180

181181
- ``modifiedCount`` containing the number of modified documents
182182

183-
- ``upsertedId`` containing the ``_id`` for the upserted document.
183+
- ``upsertedId`` containing the ``_id`` for the upserted document
184+
185+
- ``upsertedCount`` containing the number of upserted documents
184186

185187
- A boolean ``acknowledged`` as ``true`` if the operation ran with
186188
:term:`write concern` or ``false`` if write concern was disabled
@@ -659,7 +661,8 @@ Since ``upsert:true`` the document is ``inserted`` based on the ``filter`` and
659661
"acknowledged" : true,
660662
"matchedCount" : 0,
661663
"modifiedCount" : 0,
662-
"upsertedId" : 4
664+
"upsertedId" : 4,
665+
"upsertedCount": 1
663666
}
664667

665668
The collection now contains the following documents:

0 commit comments

Comments
 (0)