i want to execute the following query, but i dont know how to handle the parameters. As you can see, i need to know leaf,ws and r inside the apoc.when. How am I supposed to set the parameters?
MATCH (ws:Workspace{wsId:1})-[r:OP]->(leaf:Event) WITH leaf,ws, r
CALL apoc.do.when(leaf IS NULL,"CREATE (ws)-[:OP]->(e:Event{elementId:1, name:'TestElem1'})","DELETE r WITH ws,leaf CREATE (ws)-[:OP]->(e:Event{elementId:1, name:'TestElem1'})-[:OP]->(leaf)",{}) YIELD value
The error is because your query concludes with a “call” that has a “yield” without a “return”. Add a “return”
You pass parameters to the apoc.do.when method with a map of your parameters.
Try this:
MATCH (ws:Workspace{wsId:1})-[r:OP]->(leaf:Event)
WITH leaf,ws, r
CALL apoc.do.when(
leaf IS NULL,
"CREATE (ws)-[:OP]->(e:Event{elementId:1, name:'TestElem1'})",
"DELETE r WITH ws,leaf CREATE (ws)-[:OP]->(e:Event{elementId:1, name:'TestElem1'})-[:OP]->(leaf)",
{ws:ws, leaf:leaf, r:r}
) YIELD value
Return 1