Skip to content

[Ruby] CRUD - Upsert #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions source/crud/update.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ where the value of the ``name`` field is ``"Starbucks"``. The update document us

11 document(s) updated

Upsert Option
~~~~~~~~~~~~~

The ``upsert`` parameter allows you to use the ``update_one()`` and
``update_many()`` operations to perform a conditional operation:

- If the specified document exists, the command updates it.
- If the specified document does not exist, the command creates a new document
with the specified parameter.

For more information, see the :ref:`<ruby-upsert-example>` section or the :ref:`options
table <ruby-update-options-table>` on this page.

Customize the Update Operation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

.. _ruby-update-options-table:

.. list-table::
:widths: 30 70
:header-rows: 1
Expand Down Expand Up @@ -161,6 +176,8 @@ configure the update operation:
</reference/command/update/#std-label-update-let-syntax>` in the
{+mdb-server+} manual.

.. _ruby-upsert-example:

Modify Update Example
`````````````````````

Expand Down
Loading