Skip to content

Commit 9141e9a

Browse files
committed
add upsert section
1 parent 5f8db58 commit 9141e9a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

source/write/update.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ Each update method requires the following parameters:
6161
:manual:`Field Update Operators guide page</reference/operator/update-field/>` in the
6262
{+mdb-server+} manual.
6363

64+
Upsert Option
65+
~~~~~~~~~~~~~
66+
67+
The ``upsert`` parameter allows you to use the ``update_one()`` and
68+
``update_many()`` operations to use one method to perform a conditional
69+
operation:
70+
71+
- If the specified document exists, the command updates it
72+
- If the specified document does not exist, the command creates a new document
73+
with the specified parameter.
74+
75+
For more information, see the :ref:`<ruby-upsert-example>`
76+
on this page, or the :ref:`<ruby-update-options-table>`.
77+
6478
Update One Document Example
6579
~~~~~~~~~~~~~~~~~~~~~~~~~~~
6680

@@ -117,6 +131,8 @@ operation with default settings.
117131
The following table describes the options that you can use to
118132
configure the update operation:
119133

134+
.. _ruby-update-options-table:
135+
120136
.. list-table::
121137
:widths: 30 70
122138
:header-rows: 1
@@ -161,6 +177,8 @@ configure the update operation:
161177
</reference/command/update/#std-label-update-let-syntax>` in the
162178
{+mdb-server+} manual.
163179

180+
.. _ruby-upsert-example:
181+
164182
Modify Update Example
165183
`````````````````````
166184

0 commit comments

Comments
 (0)