apoc.case

Procedure

apoc.case(conditionals [Any], elseQuery String, params Map) - for each pair of conditional and read-only queries in the given list, this procedure will run the first query for which the conditional is evaluated to true. If none of the conditionals are true, the ELSE query will run instead.

Signature

apoc.case(conditionals :: LIST? OF ANY?, elseQuery =  :: STRING?, params = {} :: MAP?) :: (value :: MAP?)

Input parameters

Name Type Default

conditionals

LIST? OF ANY?

null

elseQuery

STRING?

params

MAP?

{}

Output parameters

Name Type

value

MAP?

Usage examples

CALL apoc.case([
  false, 'RETURN "firstFalse" as b',
  false, 'RETURN "secondFalse" as b',
  true, 'RETURN "firstTrue" as b'
]);
Table 1. Results
value

{b: "firstTrue"}

CALL apoc.case([
  false, 'RETURN "firstFalse" as b',
  false, 'RETURN "secondFalse" as b',
  false, 'RETURN "thirdFalse" as b'
  ],
  'RETURN "elseBranch" as b'
);
Table 2. Results
value

{b: "elseBranch"}