Reputation: 15
I'm trying to merge my assembly to several components using the code below
UNWIND $data as row
MERGE (a:Assembly)
ON CREATE SET a+= row
WITH a
UNWIND $components as components
FOREACH(id IN components.uuid | MATCH (c:Component {_uuid: id})
MERGE (a)-[:RECIPE]->(c))
However I get an error that doesnt allow match in FOREACH. If I just use merge then I will be creating new component nodes and not match them to the components that i already have. I am looking for a query that can help me solve this task
Disclaimer: I see a simalar question in overflow but i dont quite understand the answer given as such I put my own problem.
Upvotes: 0
Views: 1926
Reputation: 6534
Unfortunately you cannot use MATCH
statement in a FOREACH
clause, you can use the MERGE
though. If that would work for you it is ok, otherwise you could use a second UNWIND
statement. Btw.. how come you are using both UNWIND
and FOREACH
? Do you have a double nested data structure?
Upvotes: 2