Skip to content

Commit

Permalink
Add an example of select(update()) to the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttrinh committed Jan 16, 2024
1 parent ead4189 commit c77b3f5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/update.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ You can conditionally update a property by using an :ref:`optional parameter
}))
);
Note that ``e.update`` will return just the `{ id: true }` of the updated object. If you want to select further properties, you can wrap the update in a `e.select` call.

.. code-block:: typescript
e.params({ id: e.uuid, title: e.optional(e.str) }, (params) =>
e.select(
e.update(e.Movie, (movie) => ({
filter_single: { id: params.id },
set: {
title: e.op(params.title, "??", movie.title),
},
})),
(movie) => ({
title: movie.title,
}),
),
);
Updating links
^^^^^^^^^^^^^^
Expand Down

0 comments on commit c77b3f5

Please sign in to comment.