trigger

package
v1.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package trigger provides APOC trigger functions.

This package implements all apoc.trigger.* functions for managing database triggers and event handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(name, statement string, selector map[string]interface{}) error

Add adds a new trigger.

Example:

apoc.trigger.add('onPersonCreate', 'MATCH (n:Person) SET n.created = timestamp()', {})

func After

func After(name, statement string) error

After creates an after trigger.

Example:

apoc.trigger.after('audit', statement)

func AfterAsync

func AfterAsync(name, statement string) error

AfterAsync creates an asynchronous after trigger.

Example:

apoc.trigger.afterAsync('notification', statement)

func Before

func Before(name, statement string) error

Before creates a before trigger.

Example:

apoc.trigger.before('validation', statement)

func Count

func Count() int

Count returns the number of triggers.

Example:

apoc.trigger.count() => 5

func Disable

func Disable(name string) error

Disable disables a trigger.

Example:

apoc.trigger.disable('trigger1')

func Drop

func Drop(name string) error

Drop drops a trigger.

Example:

apoc.trigger.drop('trigger1')

func Enable

func Enable(name string) error

Enable enables a trigger.

Example:

apoc.trigger.enable('trigger1')

func Import

func Import(triggerDefs []*Trigger) error

Import imports trigger definitions.

Example:

apoc.trigger.import(triggers) => imported

func Install

func Install(database, name, statement string, selector map[string]interface{}) error

Install installs a trigger from definition.

Example:

apoc.trigger.install('db', 'trigger1', statement, selector)

func IsEnabled

func IsEnabled(name string) bool

IsEnabled checks if a trigger is enabled.

Example:

apoc.trigger.isEnabled('trigger1') => true/false

func NodeByLabel

func NodeByLabel(label, statement string) error

NodeByLabel creates a trigger for nodes with specific label.

Example:

apoc.trigger.nodeByLabel('Person', 'SET n.processed = true')

func OnCreate

func OnCreate(label, statement string) error

OnCreate creates a trigger for create events.

Example:

apoc.trigger.onCreate('Person', statement)

func OnDelete

func OnDelete(label, statement string) error

OnDelete creates a trigger for delete events.

Example:

apoc.trigger.onDelete('Person', statement)

func OnUpdate

func OnUpdate(label, statement string) error

OnUpdate creates a trigger for update events.

Example:

apoc.trigger.onUpdate('Person', statement)

func Pause

func Pause(name string) error

Pause pauses a trigger.

Example:

apoc.trigger.pause('onPersonCreate')

func RelationshipByType

func RelationshipByType(relType, statement string) error

RelationshipByType creates a trigger for relationships of specific type.

Example:

apoc.trigger.relationshipByType('KNOWS', 'SET r.created = timestamp()')

func Remove

func Remove(name string) error

Remove removes a trigger.

Example:

apoc.trigger.remove('onPersonCreate')

func RemoveAll

func RemoveAll() error

RemoveAll removes all triggers.

Example:

apoc.trigger.removeAll()

func Resume

func Resume(name string) error

Resume resumes a trigger.

Example:

apoc.trigger.resume('onPersonCreate')

func Stats

func Stats() map[string]int

Stats returns trigger statistics.

Example:

apoc.trigger.stats() => {total: 5, enabled: 3, disabled: 2}

Types

type Trigger

type Trigger struct {
	Name      string
	Statement string
	Selector  map[string]interface{}
	Params    map[string]interface{}
	Enabled   bool
	Phase     string // before, after, afterAsync
}

Trigger represents a database trigger.

func Export

func Export() []*Trigger

Export exports trigger definitions.

Example:

apoc.trigger.export() => trigger definitions

func List

func List() []*Trigger

List lists all triggers.

Example:

apoc.trigger.list() => [{name: 'trigger1', ...}]

func Show

func Show(name string) (*Trigger, error)

Show shows a specific trigger.

Example:

apoc.trigger.show('onPersonCreate') => trigger details

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL