如何向 AgensGraph 中的节点添加一个新的 属性?

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

我想使用 SET 子句向节点添加新的 属性。但是出现错误,查询没有执行。

1) 第一条命令和错误消息:

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) 第二个命令和错误消息:

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";

为了向节点添加新的 属性,我编写了 1) 这样的查询。我用2)这样的双引号代替了,因为单引号出错了。但是,2) 查询也会导致错误。

如何向节点添加新的属性?

AgensGraph 通过使用 jsonb 类型支持节点和关系的属性。因此,如果要将字符串值添加为 属性,该值必须是有效的 JSON 字符串,例如 '"Playing the guitar"'。写这样的查询有点不方便,但目前就是这样。