Reputation: 1
I have a requirement to delete ALL nodes and relationships from a parent/root node and NOT delete the parent/root node. The graph Database contains 2 labels (User and Contact) to group the nodes.
Currently I am able accomplish this with the following script, where '6' is the parent/node
MATCH (u:User)-[r]-(c:Contact)
WHERE u.email = '[email protected]' AND ID(c) > 6
DELETE c, r
Is there a better way to do this?
Is there a way to tell Neo4J not to delete the parent/root node?
Upvotes: 0
Views: 206
Reputation: 1
The issue is that I have to know the node id. I was hoping to just match a property on the parent node to identify it vs. node id.
Something like this:
MATCH (u:User)-[r]-(c:Contact) WHERE u.email = '[email protected]' AND NOT u.mail = '[email protected]' DELETE c, r
Which does not seem to work, any suggestions ?
Upvotes: 0
Reputation: 41676
That's a good way, what is your issue with it?
You told Neo4j not to delete the User node.
Upvotes: 0