My objective is to delete a node along with all its relationships in a single shot in neo4j graph database.
So far, I have been following this approach,
- Get all the relationships(BOTH direction) for a node
- delete the relationships
- finally delete the node.
Is this the standard approach or anything else available? I don't intend to use Cypher query for this. I want to achieve this through Java core API itself.
when using java API the described steps are correct:
try (Transaction tx = graphDb.beginTx()) {
Node node = // my node to delete
for (Relationship r : node.getRelationships()) {
r.delete();
}
node.delete();
tx.success();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.