apoc.when

Procedure APOC Core

apoc.when(condition, ifQuery, elseQuery:'', params:{}) yield value - based on the conditional, executes read-only ifQuery or elseQuery with the given parameters

Signature

apoc.when(condition :: BOOLEAN?, ifQuery :: STRING?, elseQuery =  :: STRING?, params = {} :: MAP?) :: (value :: MAP?)

Input parameters

Name Type Default

condition

BOOLEAN?

null

ifQuery

STRING?

null

elseQuery

STRING?

params

MAP?

{}

Output parameters

Name Type

value

MAP?

Usage Examples

CALL apoc.when(false, 'RETURN 7 as b');
Table 1. Results
value

{}

CALL apoc.when(true, 'RETURN $a + 7 as b', 'RETURN $a as b',{a:3})
Table 2. Results
value

{b: 10}