apoc.trigger.dropAll

Details

Syntax

apoc.trigger.dropAll(databaseName) :: (name, query, selector, params, installed, paused)

Description

Eventually removes all triggers from the given database.

Input arguments

Name

Type

Description

databaseName

STRING

The name of the database to drop the triggers from.

Return arguments

Name

Type

Description

name

STRING

The name of the trigger.

query

STRING

The query belonging to the trigger.

selector

MAP

{ phase = "before" :: ["before", "rollback", "after", "afterAsync"] }

params

MAP

The parameters for the given Cypher statement.

installed

BOOLEAN

Whether or not the trigger was installed.

paused

BOOLEAN

Whether or not the trigger was paused.

Enable Triggers

By default triggers are disabled. We can enable them by setting the following property in apoc.conf:

apoc.conf
apoc.trigger.enabled=true
apoc.trigger.refresh=60000
Description
Option Key Value Description

apoc.trigger.enabled

true/false, default false

Enable/Disable the feature

apoc.trigger.refresh

number, default 60000

Interval in ms after which a replication check is triggered across all cluster nodes

Usage Examples

The apoc.trigger.* procedures are intended to be executed in the system database, therefore they have to be executed by opening a system database session.

There are several ways of doing this:

  • When using Cypher-shell or Neo4j Browser, prefix Cypher queries with :use system

  • When using Fabric, prefix Cypher queries with USE system

  • When using the drivers, open a session directly against the system database

Moreover, the apoc.trigger procedures accept as first parameter the name of the database in which the triggers should be installed, updated, or removed.

Installing, updating, or removing a trigger is an eventually consistent operation. Therefore, they are not immediately added/updated/removed, but have a refresh rate handled by the APOC configuration apoc.trigger.refresh=<MILLISECONDS>, with default 60000 (milliseconds).

It is possible to remove all previously installed triggers from the given database by running the following query:

CALL apoc.trigger.dropAll('neo4j');
Results
name query selector params installed paused

"count-removals"

MATCH (c:Counter) SET c.count = c.count + size([f IN $deletedNodes WHERE id(f)  0])

{}

{}

FALSE

FALSE