apoc.custom.asProcedure

Procedure APOC Full Deprecated

apoc.custom.asProcedure(name, statement, mode, outputs, inputs, description) - register a custom cypher procedure

Signature

apoc.custom.asProcedure(name :: STRING?, statement :: STRING?, mode = read :: STRING?, outputs = null :: LIST? OF LIST? OF STRING?, inputs = null :: LIST? OF LIST? OF STRING?, description =  :: STRING?) :: VOID

Input parameters

Name Type Default

name

STRING?

null

statement

STRING?

null

mode

STRING?

read

outputs

LIST? OF LIST? OF STRING?

null

inputs

LIST? OF LIST? OF STRING?

null

description

STRING?

Usage Examples

We can create the function custom.powers that returns a stream of the powers of the first parameter, up to and including the power provided by the second parameter:

CALL apoc.custom.asProcedure(
  'powers',
  'UNWIND range(0, $power) AS power
   RETURN $input ^ power AS answer',
  'read',
  [['answer', 'long']],
  [['input','long'],  ['power', 'long']]
);

We can use this function, to return 9°, 9¹, 9², and 9³, as shown in the query below:

CALL custom.powers(9, 3);
Table 1. Results
answer

1.0

9.0

81.0

729.0