Reputation: 69
There are 2 nodes
There is a relationship between 2 nodes called shared
(:User{name:'John'}) -[share:shared]-> (:Posts{name:'1'})
The user has shared news 5 times, so count(share)
is 5. Now I need to remove 1 share. i.e. count(share)
needs to be changed to 4.
How can this be achieved?
Upvotes: 0
Views: 30
Reputation: 66967
I presume that:
User
node and 1 Posts
node), andPosts
node only has a single incoming shared
relationshipThis is how you'd delete one shared
relationship for 'John' if you don't care which post gets unshared (and you don't want to delete that post's node):
MATCH (:User {name:'John'})-[share:shared]->(:Posts)
WITH share LIMIT 1
DELETE share;
On the other hand, if you wanted to specifically delete the shared
relationship between 'John' and the post with the name
of '4' (assuming you don't want to delete that post's node):
MATCH (:User {name:'John'})-[share:shared]->(:Posts {name: '4'})
DELETE share;
Upvotes: 1
Reputation: 7458
With something like that :
MATCH (:User{name:'John'}) -[share:shared]-> (:Posts{name:'1'})
WITH share LIMIT 1
DELETE share
Upvotes: 0