I am cloning a group of nodes, but before doing so, I want to write a new property SET n.uuid = n.uuidoriginal, but I am having troubles then with collect. This way the input and output cloned nodes have different uuid, but the same uuidoriginal. Any ideas?
MATCH (n) WHERE id(n) in {{"My nodes":nodeset}}
WITH collect(n) as nodes
CALL apoc.refactor.cloneNodes(nodes, true, ["uuid"])
YIELD input, output
SET output:Merged
SET output.uuid = apoc.create.uuid()
return input, output
MATCH (n) WHERE id(n) in [1]
WITH collect(n) as nodes
FOREACH(i in nodes | SET i.uuidoriginal = i.uuid)
WITH nodes
CALL apoc.refactor.cloneNodes(nodes, true, ["uuid"])
YIELD input, output
SET output:Merged
SET output.uuid = apoc.create.uuid()
return input, output
I think you reversed the SET expression. Do you want to preserve the original uuid, so it would be in both nodes? I changed the code just in case, so it preserves the original uuid in the i.uuidoriginal attribute.