@@ -97,12 +97,11 @@ Modify Find and Delete Behavior
97
97
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
98
98
99
99
You can optionally modify the behavior of the ``find_one_and_delete()``
100
- method by passing a ``FineOneAndDeleteOptions`` instance as a parameter.
101
- To use default values for each setting, specify the value ``None`` for
102
- the options parameter.
100
+ method by chaining option builder methods to ``find_one_and_delete()``. These
101
+ builder methods set ``FindOneAndDeleteOptions`` struct fields.
103
102
104
103
The following table describes the options available in
105
- ``FineOneAndDeleteOptions ``:
104
+ ``FindOneAndDeleteOptions ``:
106
105
107
106
.. list-table::
108
107
:widths: 30 70
@@ -175,13 +174,15 @@ The following table describes the options available in
175
174
176
175
.. TODO add links to guides for relevant options
177
176
178
- The {+driver-short+} implements the Builder design pattern for the
179
- creation of a ``FindOneAndDeleteOptions`` instance. You can use the
180
- type's ``builder()`` method to construct an options instance by
181
- chaining option builder functions one at a time.
177
+ .. note:: Setting Options
178
+
179
+ You can set ``FindOneAndDeleteOptions`` fields by chaining option builder methods directly
180
+ to the ``find_one_and_delete()`` method call. If you're using an earlier version of the driver,
181
+ you must construct a ``FindOneAndDeleteOptions`` instance by chaining option builder methods
182
+ to the ``builder()`` method. Then, pass your options instance as a parameter to ``find_one_and_delete()``.
182
183
183
- The following code shows how to construct a ``FindOneAndDeleteOptions``
184
- instance and pass it to the ``find_one_and_delete()`` method:
184
+ The following code shows how to set the ``comment`` field by chaining
185
+ the ``comment()`` method to the ``find_one_and_delete()`` method:
185
186
186
187
.. literalinclude:: /includes/fundamentals/code-snippets/crud/compound.rs
187
188
:start-after: begin-find-delete-options
@@ -236,12 +237,11 @@ Modify Find and Update Behavior
236
237
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
237
238
238
239
You can optionally modify the behavior of the ``find_one_and_update()``
239
- method by passing a ``FindOneAndUpdateOptions`` instance as a parameter.
240
- To use default values for each setting, specify the value ``None`` for
241
- the options parameter.
240
+ method by chaining option builder methods to ``find_one_and_update()``. These
241
+ builder methods set ``FindOneAndUpdateOptions`` struct fields.
242
242
243
243
The following table describes the options available in
244
- ``FineOneAndDeleteOptions ``:
244
+ ``FindOneAndUpdateOptions ``:
245
245
246
246
.. list-table::
247
247
:widths: 30 70
@@ -343,13 +343,8 @@ The following table describes the options available in
343
343
.. TODO add link to array updates page under option
344
344
.. TODO add links to guides for relevant options
345
345
346
- The {+driver-short+} implements the Builder design pattern for the
347
- creation of a ``FindOneAndUpdateOptions`` instance. You can use the
348
- type's ``builder()`` method to construct an options instance by
349
- chaining option builder methods one at a time.
350
-
351
- The following code shows how to construct a ``FindOneAndUpdateOptions``
352
- instance and pass it to the ``find_one_and_update()`` method:
346
+ The following code shows how to set the ``comment`` field by chaining
347
+ the ``comment()`` method to the ``find_one_and_update()`` method:
353
348
354
349
.. literalinclude:: /includes/fundamentals/code-snippets/crud/compound.rs
355
350
:start-after: begin-find-update-options
@@ -361,15 +356,15 @@ instance and pass it to the ``find_one_and_update()`` method:
361
356
Find and Update Example
362
357
~~~~~~~~~~~~~~~~~~~~~~~
363
358
364
- This example shows how to call the ``find_one_and_update()`` method with the
365
- following parameters:
359
+ This example shows how to perform the following actions:
366
360
367
- - A query filter that matches a document where the value of ``school``
368
- is ``"Aurora High School"``
369
- - An update document that sets the ``school`` field to ``"Durango High School"``
370
- and increments the ``age`` field by ``1``
371
- - A ``FindOneAndUpdateOptions`` instance that returns the document
372
- *after* the update
361
+ - Call the ``find_one_and_update()`` method
362
+ - Pass a query filter to ``find_one_and_update()`` that matches a document where the
363
+ value of ``school`` is ``"Aurora High School"``
364
+ - Pass an update document to ``find_one_and_update()`` that sets the ``school`` field to
365
+ ``"Durango High School"`` and increments the ``age`` field by ``1``
366
+ - Chain the ``return_document()`` method to ``find_one_and_update()`` to return
367
+ the matched document *after* the update
373
368
374
369
.. io-code-block::
375
370
:copyable: true
@@ -411,9 +406,8 @@ Modify Find and Replace Behavior
411
406
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
412
407
413
408
You can optionally modify the behavior of the ``find_one_and_replace()``
414
- method by passing a ``FindOneAndReplaceOptions`` instance as a parameter.
415
- To use default values for each setting, specify the value ``None`` for
416
- the options parameter.
409
+ method by chaining option builder methods to ``find_one_and_replace()``. These
410
+ builder methods set ``FindOneAndReplaceOptions`` struct fields.
417
411
418
412
The following table describes the options available in
419
413
``FindOneAndReplaceOptions``:
@@ -511,14 +505,9 @@ The following table describes the options available in
511
505
512
506
.. TODO add link to array updates page under option
513
507
.. TODO add links to guides for relevant options
514
-
515
- The {+driver-short+} implements the Builder design pattern for the
516
- creation of a ``FindOneAndReplaceOptions`` instance. You can use the
517
- type's ``builder()`` method to construct an options instance by
518
- chaining option builder functions one at a time.
519
508
520
- The following code shows how to construct a ``FindOneAndReplaceOptions``
521
- instance and pass it to the ``find_one_and_replace()`` method:
509
+ The following code shows how to set the ``comment`` field by chaining
510
+ the ``comment()`` method to the ``find_one_and_replace()`` method:
522
511
523
512
.. literalinclude:: /includes/fundamentals/code-snippets/crud/compound.rs
524
513
:start-after: begin-find-replace-options
@@ -530,15 +519,17 @@ instance and pass it to the ``find_one_and_replace()`` method:
530
519
Find and Replace Example
531
520
~~~~~~~~~~~~~~~~~~~~~~~~
532
521
533
- This example shows how to call the ``find_one_and_replace()`` method with the
534
- following parameters:
535
-
536
- - A query filter that matches a document where the value of ``name``
537
- includes the string ``"Johnson"``
538
- - A replacement document that describes a new student
539
- - A ``FindOneAndReplaceOptions`` instance that returns the document
540
- after replacement and projects only the ``name`` and ``school`` fields
541
- in the output
522
+ This example performs the following actions:
523
+
524
+ - Calls the ``find_one_and_replace()`` method
525
+ - Passes a query filter to ``find_one_and_replace()`` that matches a document
526
+ where the value of ``name`` includes the string ``"Johnson"``
527
+ - Passes a replacement document to ``find_one_and_replace()`` that describes a new
528
+ student
529
+ - Chains the ``return_document()`` method to ``find_one_and_replace()`` to return the document
530
+ after replacement
531
+ - Chains the ``projection()`` method to ``find_one_and_replace()``to project only the ``name``
532
+ and ``school`` fields in the output
542
533
543
534
.. io-code-block::
544
535
:copyable: true
0 commit comments