apoc.do.case
Syntax |
|
||
Description |
For each pair of conditional queries in the given |
||
Input arguments |
Name |
Type |
Description |
|
|
A list of conditionals, where each conditional is a pair: the first element is a predicate, and the second is a Cypher query to be executed based on that predicate. |
|
|
|
A Cypher query to evaluate if all conditionals evaluate to false. The default is: ``. |
|
|
|
A map of parameters to be used in the executed Cypher query. The default is: |
|
Return arguments |
Name |
Type |
Description |
|
|
The result returned from the evaluated Cypher query. |
Usage Examples
The following will create a node with a name
property of B
, because that’s the first of the conditionals to evaluate to true:
CALL apoc.do.case([
false,
'CREATE (a:Node{name:"A"}) RETURN a AS node',
true,
'CREATE (b:Node{name:"B"}) RETURN b AS node'
],
'CREATE (c:Node{name:"C"}) RETURN c AS node',{})
YIELD value
RETURN value.node AS node;
node |
---|
(:Node {name: "B"}) |
The following will create a node with a name
property of C
, as per the elseQuery, because all conditionals evaluate to false:
CALL apoc.do.case([
false,
'CREATE (a:Node{name:"A"}) RETURN a AS node',
false,
'CREATE (b:Node{name:"B"}) RETURN b AS node'
],
'CREATE (c:Node{name:"C"}) RETURN c AS node',{})
YIELD value
RETURN value.node AS node;
node |
---|
(:Node {name: "C"}) |