@@ -27,10 +27,8 @@ removes all fields and values from a specified document except the
27
27
operations differs from an update operation, which changes only
28
28
specified fields in one or more documents.
29
29
30
- .. tip:: Learn About Update Operations
31
-
32
- To learn more about update operations, see the
33
- :ref:`kotlin-sync-write-update` guide.
30
+ To learn more about update operations, see the
31
+ :ref:`kotlin-sync-write-update` guide.
34
32
35
33
Sample Data
36
34
~~~~~~~~~~~
@@ -85,9 +83,10 @@ value is ``"Primola Restaurant"``:
85
83
86
84
.. important::
87
85
88
- The values of ``_id`` fields are immutable. If your replacement document specifies
89
- a value for the ``_id`` field, it must be the same as the ``_id`` value of the
90
- existing document.
86
+ The values of ``_id`` fields are immutable. If your replacement
87
+ document specifies a value for the ``_id`` field, it must be the same
88
+ as the ``_id`` value of the existing document or the driver raises a
89
+ ``WriteError``.
91
90
92
91
Customize the Replace Operation
93
92
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -141,13 +140,10 @@ configure an ``ReplaceOptions`` instance:
141
140
* - ``comment()``
142
141
- | Sets a comment to attach to the operation.
143
142
144
- The following code uses the ``replaceOne()`` method to match the first
145
- document in which the value of the ``name`` field is ``"Pizza Plus"``,
146
- then replaces the fields with new fields.
147
-
148
- Because the ``upsert`` option is set to ``true``, the driver inserts a
149
- new document that has the fields and values specified in the replacement
150
- document if the query filter doesn't match any existing documents.
143
+ The following code sets the ``upsert`` option ``true``, instructing the
144
+ driver to insert a new document that has the fields and values specified
145
+ in the replacement document if the query filter doesn't match any
146
+ existing documents:
151
147
152
148
.. literalinclude:: /includes/write/replace.kt
153
149
:start-after: start-replace-options
@@ -171,19 +167,19 @@ an ``UpdateResult`` instance:
171
167
- Description
172
168
173
169
* - ``getMatchedCount()``
174
- - | Indicates the number of documents that matched the query filter, regardless of
170
+ - | Returns the number of documents that matched the query filter, regardless of
175
171
how many updates were performed.
176
172
177
173
* - ``getModifiedCount()``
178
- - | Indicates number of documents modified by the update operation. If an updated
174
+ - | Returns the number of documents modified by the update operation. If an updated
179
175
document is identical to the original, it is not included in this
180
176
count.
181
177
182
178
* - ``wasAcknowledged()``
183
179
- | Returns ``true`` if the server acknowledged the result.
184
180
185
181
* - ``getUpsertedId()``
186
- - | Specifies the ``_id`` value of the document that was upserted
182
+ - | Returns the ``_id`` value of the document that was upserted
187
183
in the database, if the driver performed an upsert.
188
184
189
185
Additional Information
0 commit comments