Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update a nested object in EdgeDB?

Tags:

edgedb

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?

like image 268
monomonedula Avatar asked Mar 26 '26 08:03

monomonedula


1 Answers

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 };
like image 167
raddevon Avatar answered Apr 02 '26 12:04

raddevon