Update objects with the e.update
function.
e.update(e.Movie, movie => ({
filter_single: {title: "Avengers 4"},
set: {
title: "Avengers: Endgame"
}
}))
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)
}
}))
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_single: {title: 'The Eternals'},
set: {
actors: actors,
}
}))
Add to a link
const actors = e.select(e.Person, ...);
e.update(e.Movie, movie => ({
filter_single: {title: 'The Eternals'},
set: {
actors: { "+=": actors },
}
}))
Subtract from a link
const actors = e.select(e.Person, ...);
e.update(e.Movie, movie => ({
filter_single: {title: 'The Eternals'},
set: {
actors: { "-=": actors },
}
}))
You can use a for loop to perform bulk updates.