I separate my Neo4j database into isolated sub-databases using labels. During development, I frequently need to wipe an entire sub-database clean. Currently I do this with:
MATCH (n:myLabel)-[r]-() DELETE n, r
MATCH (n:myLabel) DELETE n
I need two queries because I have to delete all relationships, at the same time as their nodes, but I don't know how to match unconnected nodes simultaneously. Is there a way to wipe out a whole subgraph marked by a label in a single query? I'm on Neo4j 2.2.1
Here you go:
MATCH (n:myLabel) OPTIONAL MATCH (n)-[r]-() DELETE n, r
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With