Documentation
¶
Overview ¶
Package trigger provides APOC trigger functions.
This package implements all apoc.trigger.* functions for managing database triggers and event handlers.
Index ¶
- func Add(name, statement string, selector map[string]interface{}) error
- func After(name, statement string) error
- func AfterAsync(name, statement string) error
- func Before(name, statement string) error
- func Count() int
- func Disable(name string) error
- func Drop(name string) error
- func Enable(name string) error
- func Import(triggerDefs []*Trigger) error
- func Install(database, name, statement string, selector map[string]interface{}) error
- func IsEnabled(name string) bool
- func NodeByLabel(label, statement string) error
- func OnCreate(label, statement string) error
- func OnDelete(label, statement string) error
- func OnUpdate(label, statement string) error
- func Pause(name string) error
- func RelationshipByType(relType, statement string) error
- func Remove(name string) error
- func RemoveAll() error
- func Resume(name string) error
- func Stats() map[string]int
- type Trigger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Add adds a new trigger.
Example:
apoc.trigger.add('onPersonCreate', 'MATCH (n:Person) SET n.created = timestamp()', {})
func AfterAsync ¶
AfterAsync creates an asynchronous after trigger.
Example:
apoc.trigger.afterAsync('notification', statement)
func Before ¶
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 Import ¶
Import imports trigger definitions.
Example:
apoc.trigger.import(triggers) => imported
func Install ¶
Install installs a trigger from definition.
Example:
apoc.trigger.install('db', 'trigger1', statement, selector)
func IsEnabled ¶
IsEnabled checks if a trigger is enabled.
Example:
apoc.trigger.isEnabled('trigger1') => true/false
func NodeByLabel ¶
NodeByLabel creates a trigger for nodes with specific label.
Example:
apoc.trigger.nodeByLabel('Person', 'SET n.processed = true')
func OnCreate ¶
OnCreate creates a trigger for create events.
Example:
apoc.trigger.onCreate('Person', statement)
func OnDelete ¶
OnDelete creates a trigger for delete events.
Example:
apoc.trigger.onDelete('Person', statement)
func OnUpdate ¶
OnUpdate creates a trigger for update events.
Example:
apoc.trigger.onUpdate('Person', statement)
func RelationshipByType ¶
RelationshipByType creates a trigger for relationships of specific type.
Example:
apoc.trigger.relationshipByType('KNOWS', 'SET r.created = timestamp()')
func RemoveAll ¶
func RemoveAll() error
RemoveAll removes all triggers.
Example:
apoc.trigger.removeAll()
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