Update query in grakn


how to write update query in grakn ? for example i want to edit name of a movie in my database.how can i do that?at first i am searching the movie by match query and then use insert query for insert new name for that , but after that , my searched movie has two names and previous name still exists. please help me !!

my query : match $x isa movie has name “abc” ;insert $x has name “newabc”;


Hi @emad.kha,

So at the moment you can’t update resources. You have to delete the links to them and add them back in. So for example:

match $x isa movie has name "abc" ;
insert $x has name "newabc";

will actually give $x 2 names.

To perform the update you want you would have to do the following

//Get rid of the old resource link
    $name val "abc" isa name;
    $x isa movie has name "abc" ;
    $r (has-name-owner: $x, has-name-value: $y) isa has-name;
delete $r;

//Add in the new one;
insert $x has name "newabc";

The current way of removing the resource links is overly verbose. Luckily we are adding in a shorthand to help with that in the next release of Grakn.

I hope that helps for the moment.