apoc.refactor.to
Syntax |
|
||
Description |
Redirects the given |
||
Input arguments |
Name |
Type |
Description |
|
|
The relationship to redirect. |
|
|
|
The new end node the relationship should point to. |
|
Return arguments |
Name |
Type |
Description |
|
|
The id of the given relationship. |
|
|
|
The id of the new relationship with the updated type. |
|
|
|
The message if an error occurred. |
Usage Examples
The examples in this section are based on the following graph:
MERGE (person1:Person {name: "Michael"})
MERGE (person2:Person {name: "Ryan"})
MERGE (person3:Person {name: "Jennifer"})
MERGE (person1)-[:FRIENDS]->(person2);
The following makes Jennifer the end node in the FOLLOWS
relationship instead of Ryan:
MATCH (:Person {name: "Michael"})-[rel:FRIENDS]->()
MATCH (jennifer:Person {name: "Jennifer"})
CALL apoc.refactor.to(rel, jennifer)
YIELD input, output
RETURN input, output;
If we execute this query, it will result in the following output:
input | output |
---|---|
32 |
[:`FRIENDS`] |
And the graph now looks like this: