apoc.refactor.cloneNodes
Procedure
apoc.refactor.cloneNodes(nodes [Node], withRelationships Boolean, skipProperties [String])
- clones the given nodes with their labels and properties.
It is possible to skip any node properties using skipProperties (note: this only skips properties on nodes and not their relationships).
Signature
apoc.refactor.cloneNodes(nodes :: LIST? OF NODE?, withRelationships = false :: BOOLEAN?, skipProperties = [] :: LIST? OF STRING?) :: (input :: INTEGER?, output :: NODE?, error :: STRING?)
Input parameters
Name | Type | Default |
---|---|---|
nodes |
LIST? OF NODE? |
null |
withRelationships |
BOOLEAN? |
false |
skipProperties |
LIST? OF STRING? |
[] |
Usage Examples
The examples in this section are based on the following sample graph:
CREATE (mark:Person {name: "Mark", city: "London"})
CREATE (jennifer:Person {name: "Jennifer", city: "St Louis"});
The following creates copies of all Person
nodes:
MATCH (p:Person)
WITH collect(p) AS people
CALL apoc.refactor.cloneNodes(people)
YIELD input, output
RETURN input, output;
input | output |
---|---|
4 |
(:Person {name: "Mark", city: "London"}) |
5 |
(:Person {name: "Jennifer", city: "St Louis"}) |
We can list all the Person
nodes by running the following query:
MATCH (p:Person)
RETURN p;
p |
---|
(:Person {name: "Mark", city: "London"}) |
(:Person {name: "Jennifer", city: "St Louis"}) |
(:Person {name: "Mark", city: "London"}) |
(:Person {name: "Jennifer", city: "St Louis"}) |
Was this page helpful?