Hi guys.
I have node user and node post. So user can either like or dislike that post. When he likes post i create LIKED relationship between user and post, but if user then dislike it i will create DISLIKE relationship but LIKED still remains. How can i create one relationship and delete other one?
This is my query:
MATCH (user:User), (post:Post)
WHERE user.username = '...' and post.id = '...'
MEREGE (user)-[liked:LIKED]->(post)
ON CREATE liked
SET liked.time = '...'
:param IsLiked: true
MATCH (user:User), (post:Post)
WHERE user.username = '...' and post.id = '...'
//expression when LIKED will create relationship otherwise command will skipped
FOREACH(_ in case when IsLiked then [1] else end | MERGE (user)-[:LIKED]->(post)
//expression when DISLIKED will create relationship otherwise command will skipped
FOREACH(_ in case when not IsLiked then [1] else end | MERGE (user)-[:DISLIKED]->(post)