Update

Update objects with the e.update function.


1. e.update(e.Movie, movie => ({
2. filter: e.op(movie.title, '=', e.str("Avengers 4")),
3. set: {
4. title: "Avengers: Endgame"
5. }
6. }))

The parameter object supports the full set of clauses for filtering, ordering, and pagination.


1. e.update(e.Movie, movie => ({
2. filter: ...,
3. order_by: ...,
4. offset: ...,
5. limit: ...,
6. set: {
7. // ...
8. }
9. }))

You can reference the current value of the object’s properties.


1. e.update(e.Movie, movie => ({
2. filter: e.op(movie.title[0], '=', ' '),
3. set: {
4. title: e.str_trim(movie.title)
5. }
6. }))

EdgeQL supports some convenient syntax for appending to, subtracting from, and overwriting links.


1. update Movie set {
2. # overwrite
3. actors := Person,

5. # add to link
6. actors += Person,

8. # subtract from link
9. actors -= Person
10. }

In the query builder this is represented with the following syntax.

Overwrite a link


1. const actors = e.select(e.Person, ...);
2. e.update(e.Movie, movie => ({
3. filter: e.op(movie.title, '=', 'The Eternals'),
4. set: {
5. actors: actors,
6. }
7. }))

Add to a link


1. const actors = e.select(e.Person, ...);
2. e.update(e.Movie, movie => ({
3. filter: e.op(movie.title, '=', 'The Eternals'),
4. set: {
5. actors: { "+=": actors },
6. }
7. }))

Subtract from a link


1. const actors = e.select(e.Person, ...);
2. e.update(e.Movie, movie => ({
3. filter: e.op(movie.title, '=', 'The Eternals'),
4. set: {
5. actors: { "-=": actors },
6. }
7. }))