如果用户尚不存在,我正在尝试创建用户,然后知道是否创建了。
此语法始终执行第二组:
MERGE (n:User {email: {email}})
ON CREATE n
SET n = {user}
SET n.created = timestamp()
WITH n WHERE n.created = timestamp()
RETURN n
我猜第二组实际上不是 ON CREATE 子句的一部分,如下所示:
MERGE (n:User {email: {email}})
ON CREATE n
SET n = {user}
SET n.created = timestamp()
WITH n WHERE n.created = timestamp()
RETURN n
但是,多个集合的替代语法会导致“错误:预期的有效查询正文”:
MERGE (n:User {email: {email}})
ON CREATE n
SET n = {user}, n.created = timestamp()
WITH n WHERE n.created = timestamp()
RETURN n
作为一种解决方法,我决定将创建的时间戳与用户地图一起传递,但有没有办法做到这一点?它是按预期工作还是这里有错误,也许?