Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-06-2021 02:37 AM
I have a requirement to delete a relationship alone(not nodes) if exists and then create a new relationship with existing nodes. All two operations should occur in a single statement. Am able to delete and create at the same time, only when a relationship exists between the nodes else if there is no relationship exists statements are not executing after the delete call.
Am using apoc.do.case()
03-06-2021 08:04 PM
You probably don't need to use an apoc function for that, a simple MATCH
should suffice:
MATCH (a)-[r:old_type_of_rel]->(b)
DELETE r
CREATE (a)-[:new_type_of_rel]->(b)
If the entire match statement doesn't pass (e.g both nodes and the relationship between them must exists) then neither the DELETE
nor CREATE
will execute.
12-10-2021 07:45 AM
If relationship may or may not exist then you can try this
OPTIONAL MATCH (a)-[r:old_type_of_rel]->(b)
DELETE r
CREATE (a)-[:new_type_of_rel]->(b)
All the sessions of the conference are now available online