Reputation: 311
I want to copy a node by using cypher. Now I can get all properties by properties()
function in cypher, what is the next step? Do I have to using the driver like py2neo
to write them in python. Dose Cypher has some function like copy()
to copy the node directly?
Upvotes: 2
Views: 2847
Reputation: 4468
Update for Neo4j 5
The use of nodes or relationships for setting properties is deprecated.
You can use properties()
function instead
match (old:Mynode) create (new:Mynode) set new = properties(old)
Upvotes: 1
Reputation: 1022
call apoc cloneNodes :)
MATCH (f:Foo{name:'Foo'}),(b:Bar{name:'Bar'}) WITH f,b CALL
apoc.refactor.cloneNodes([f,b]) yield input, output RETURN *
you can read all about it and the awsomeness power of apoc here
Upvotes: 7
Reputation: 4901
Here is the simplest answer:
match (old:Mynode) create (new:Mynode) set new = old
Upvotes: 8