0

我用 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”

4

1 回答 1

4

节点上的标签是一个集合,因此您需要使用 IN 运算符:

WHERE TYPE(rel)="FOLLOW" 
AND "User" IN labels(followed)
AND "User" IN labels(follower)
于 2017-04-26T08:21:14.520 回答