propertiessetcypheragens-graph

How do I add a new property to the node in AgensGraph?


I want to add a new property to the node using SET clause. But an error is occurred and query is not executed.

1) 1st command and error message :

MATCH (j {name:'Jack'}) SET j.hobby = 'Playing the guitar';

ERROR:  invalid input syntax for type json
LINE 1: match (j {name:'Jack'}) SET j.hobby = 'Playing the guitar';
                                              ^
DETAIL:  Token "Playing" is invalid. 
CONTEXT:  JSON data, line 1: Playing...

2) 2nd command and error message :

MATCH (j {name:'Jack'}) SET j.hobby = "Playing the guitar";

ERROR:  column "Playing the guitar" does not exist
LINE 1: match (j {name:'Jack'}) SET j.hobby = "Playing the guitar";

To add a new property to the node, I wrote query like 1). I replaced it with double quotation marks like 2), because an error occurred in the single quotation marks. But, 2) query also causes an error.

How can I add a new property to the node?


Solution

  • AgensGraph supports properties on nodes and relationships by using jsonb type. So, if you want to add a string value as a property, the value must be a valid JSON string like '"Playing the guitar"'. It is somewhat inconvenient to write such queries, but that's how it currently works.