How to update a nested object in EdgeDB?

221 views Asked by At

Say I have a schema like this:

type Foo {
    required link bar -> Bar; 
}

type Bar {
    required property baz -> bool;
}

How do I, knowing the id of a Foo object, update a property of a Baz object it points to? In other words, how do I update Foo.bar.baz value knowing Foo's ID?

1

There are 1 answers

0
raddevon On BEST ANSWER

You can filter based on the backlink like this:

select Bar filter .<bar.id = <uuid>'df492862-80aa-11ed-832e-e72d12452736';

Where df492862-80aa-11ed-832e-e72d12452736 is the ID of your Foo object. That means you can update like this:

update Bar
  filter .<bar.id = <uuid>'df492862-80aa-11ed-832e-e72d12452736'
  set { baz := false };