apoc.periodic.countdown

Procedure APOC Core

This procedure is not intended to be used in a cluster environment, and may act unpredictably. It continues to execute against the same database that it was initiated on, meaning that in a cluster environment, it only executes on the leader. If there is a leader switch then the procedure may error and stop running.

apoc.periodic.countdown('name',statement,repeat-rate-in-seconds) creates a background job that will repeatedly execute the given Cypher statement until it returns 0.

Signature

apoc.periodic.countdown(name :: STRING?, statement :: STRING?, rate :: INTEGER?) :: (name :: STRING?, delay :: INTEGER?, rate :: INTEGER?, done :: BOOLEAN?, cancelled :: BOOLEAN?)

Input parameters

Name Type Default

name

STRING?

null

statement

STRING?

null

rate

INTEGER?

null

Output parameters

Name Type

name

STRING?

delay

INTEGER?

rate

INTEGER?

done

BOOLEAN?

cancelled

BOOLEAN?

Usage Examples

The examples in this section are based on the following sample graph:

CREATE (:Counter {value: 10000});
The following decrements the value once a second until it gets to 0:
CALL apoc.periodic.countdown(
  "decrement",
  "MATCH (counter:Counter)
   SET counter.value = counter.value - 1
   RETURN counter.value as count",
  1);