Skip to content
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

Document wrapping insert with select #6936

Merged
merged 3 commits into from Mar 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/edgeql/insert.rst
Expand Up @@ -117,6 +117,25 @@ You can only ``insert`` instances of concrete (non-abstract) object types.
... };
error: QueryError: cannot insert into abstract object type 'default::Person'

By default, ``insert`` 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
``insert`` with a ``select`` and apply a shape specifying any properties and
links you want returned:

.. code-block:: edgeql-repl

db> select (insert Hero {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also offer an example of a with style, which I personally prefer as a better-looking formulation:

with
   NewHero := (insert)
select
   NewHero {
      id,
      name,
   }

... name := "Spider-Man"
... # secret_identity is omitted
... }) {id, name};
{
default::Hero {
id: b0fbe9de-3e90-11ec-8c12-ffa2d5f0176a,
name: "Spider-Man"
}
}


.. _ref_eql_insert_links:

Inserting links
Expand Down