Skip to content

Commit

Permalink
Add select wrap info to update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
raddevon committed Mar 1, 2024
1 parent 16d232d commit 3107078
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions docs/edgeql/update.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,27 @@ To remove items, use ``-=``.
... filter .title = "Black Widow";
{default::Movie {num_characters: 2}}
Returning data on update
------------------------

By default, ``update`` returns only the inserted object's ``id`` as seen in the
examples above. If you want to get additional data back, you may wrap your
``update`` with a ``select`` and apply a shape specifying any properties and
links you want returned:

.. code-block:: edgeql-repl
db> select (update Hero
... filter .name = "Hawkeye"
... set { name := "Ronin" }
... ) {id, name};
{
default::Hero {
id: d476b12e-3e7b-11ec-af13-2717f3dc1d8a,
name: "Ronin"
}
}
With blocks
-----------

Expand Down Expand Up @@ -118,6 +139,27 @@ the results of a complex query.
You can pass any object-type expression into ``update``, including
polymorphic ones (as above).

You can also use ``with`` to make returning additional data from an update more
readable:

.. code-block:: edgeql-repl
db> with UpdatedHero := (update Hero
... filter .name = "Hawkeye"
... set { name := "Ronin" }
... )
... select UpdatedHero {
... id,
... name
... };
{
default::Hero {
id: d476b12e-3e7b-11ec-af13-2717f3dc1d8a,
name: "Ronin"
}
}
See also
--------

Expand Down

0 comments on commit 3107078

Please sign in to comment.