Skip to content

Commit 71666f9

Browse files
[Ruby] CRUD - Upsert (#164)
* DOCSP-51932: v2.21.2 patch release (#163) * add upsert section * reference * LM feedback * checkout snooty --------- Co-authored-by: Nora Reidy <[email protected]>
1 parent eb827e8 commit 71666f9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

source/crud/update.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@ where the value of the ``name`` field is ``"Starbucks"``. The update document us
105105

106106
11 document(s) updated
107107

108+
Upsert Option
109+
~~~~~~~~~~~~~
110+
111+
The ``upsert`` parameter allows you to use the ``update_one()`` and
112+
``update_many()`` operations to perform a conditional operation:
113+
114+
- If the specified document exists, the command updates it.
115+
- If the specified document does not exist, the command creates a new document
116+
with the specified parameter.
117+
118+
For more information, see the :ref:`<ruby-upsert-example>` section or the :ref:`options
119+
table <ruby-update-options-table>` on this page.
120+
108121
Customize the Update Operation
109122
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
110123

@@ -117,6 +130,8 @@ operation with default settings.
117130
The following table describes the options that you can use to
118131
configure the update operation:
119132

133+
.. _ruby-update-options-table:
134+
120135
.. list-table::
121136
:widths: 30 70
122137
:header-rows: 1
@@ -161,6 +176,8 @@ configure the update operation:
161176
</reference/command/update/#std-label-update-let-syntax>` in the
162177
{+mdb-server+} manual.
163178

179+
.. _ruby-upsert-example:
180+
164181
Modify Update Example
165182
`````````````````````
166183

0 commit comments

Comments
 (0)