在 Neo4j 中添加触发器时无法创建关系
Can't create relationship when add trigger in neo4j
我用 apoc.trigger.add 创建了一个触发器:
CALL apoc.trigger.add('increase_followings_and_followers',
'UNWIND {createdRelationships} AS rel
WITH rel, STARTNODE(rel) as follower, ENDNODE(rel) AS followed WITH rel, follower, followed
WHERE TYPE(rel)="FOLLOW" and labels(followed)="User" and labels(follower)="User"
SET follower.followings = follower.followings +1, followed.followers= followed.followers+1',
{phase:'after'})
我建立了一个社交网络,当一个用户关注另一个人时,触发器会自动增加关注者人数和关注人数。但它不起作用,我无法在两个用户节点
之间创建新关系 "FOLLLOW"
节点上的标签是一个集合,因此需要使用 IN 运算符:
WHERE TYPE(rel)="FOLLOW"
AND "User" IN labels(followed)
AND "User" IN labels(follower)
我用 apoc.trigger.add 创建了一个触发器:
CALL apoc.trigger.add('increase_followings_and_followers',
'UNWIND {createdRelationships} AS rel
WITH rel, STARTNODE(rel) as follower, ENDNODE(rel) AS followed WITH rel, follower, followed
WHERE TYPE(rel)="FOLLOW" and labels(followed)="User" and labels(follower)="User"
SET follower.followings = follower.followings +1, followed.followers= followed.followers+1',
{phase:'after'})
我建立了一个社交网络,当一个用户关注另一个人时,触发器会自动增加关注者人数和关注人数。但它不起作用,我无法在两个用户节点
之间创建新关系 "FOLLLOW"节点上的标签是一个集合,因此需要使用 IN 运算符:
WHERE TYPE(rel)="FOLLOW"
AND "User" IN labels(followed)
AND "User" IN labels(follower)