So, I have this (simplified) query that creates a board with a relationship to a group.
MATCH (g:Group) CREATE (g)-[:ChildBoard]->(b:Board);
Now, if there already is a board with this relationship, I want to remove that relationship and create a new, different one.
(same g as above)
MATCH (g)-[oldRel:ChildBoard]->(oldBoard:Board) DELETE oldRel CREATE (b)-[:Sibling]->(oldBoard);
I'm trying to figure out how I'd do this, preferably in one query.
This is what I've got so far:
MATCH (g:Group) OPTIONAL MATCH (g)-[oldRel:ChildBoard]->(oldBoard:Board) DELETE oldRel CREATE (g)-[:ChildBoard]->(b:Board) CREATE (b)-[:Sibling]->(oldBoard);
The problem is, when oldBoard is null, it fails. I want it to simply not create it. I know there's a setting that makes it not throw an error in situations like these, but I'd like to know if there's a better way to do it.