Update
Update objects with the e.update
function.
e.update(e.Movie, movie => ({
filter: e.op(movie.title, '=', e.str("Avengers 4")),
set: {
title: "Avengers: Endgame"
}
}))
The parameter object supports the full set of clauses for filtering, ordering, and pagination.
e.update(e.Movie, movie => ({
filter: ...,
order_by: ...,
offset: ...,
limit: ...,
set: {
// ...
}
}))
You can reference the current value of the object’s properties.
e.update(e.Movie, movie => ({
filter: e.op(movie.title[0], '=', ' '),
set: {
title: e.str_trim(movie.title)
}
}))
Updating links
EdgeQL supports some convenient syntax for appending to, subtracting from, and overwriting links.
update Movie set {
# overwrite
actors := Person,
# add to link
actors += Person,
# subtract from link
actors -= Person
}
In the query builder this is represented with the following syntax.
Overwrite a link
const actors = e.select(e.Person, ...);
e.update(e.Movie, movie => ({
filter: e.op(movie.title, '=', 'The Eternals'),
set: {
actors: actors,
}
}))
Add to a link
const actors = e.select(e.Person, ...);
e.update(e.Movie, movie => ({
filter: e.op(movie.title, '=', 'The Eternals'),
set: {
actors: { "+=": actors },
}
}))
Subtract from a link
const actors = e.select(e.Person, ...);
e.update(e.Movie, movie => ({
filter: e.op(movie.title, '=', 'The Eternals'),
set: {
actors: { "-=": actors },
}
}))