0

I created a trigger with 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'})

I build a socialnetwork, When a user follow another, trigger will auto increase follower number and following number. But It don't work and I can't create new relationship "FOLLLOW" between two User node

Vlad Dekhanov
  • 1,066
  • 1
  • 13
  • 27
kien bui
  • 1,760
  • 2
  • 17
  • 33

1 Answers1

4

The labels on a node is a collection, hence you need to use the IN operator :

WHERE TYPE(rel)="FOLLOW" 
AND "User" IN labels(followed)
AND "User" IN labels(follower)
Christophe Willemsen
  • 19,399
  • 2
  • 29
  • 36