Skip to main content
Version: Next

TriggerDef <T>

Definition of a database trigger on a table.

Index

Properties

optionalbody

body?: string | RawQueryFragment<string> | TriggerCallback<T>

SQL body of the trigger. Can be a string, Raw query, or callback receiving column name mappings.

events

events: (insert | update | delete | truncate)[]

Which DML events activate the trigger.

optionalexpression

expression?: string

Raw DDL escape hatch — full CREATE TRIGGER statement. Mutually exclusive with body.

optionalforEach

forEach?: row | statement

Whether the trigger fires once per row or per statement. Defaults to 'row'.

optionalname

name?: string

Trigger name. Auto-generated if omitted.

timing

timing: before | after | instead of

When the trigger fires relative to the event.

optionalwhen

when?: string

Optional SQL WHEN condition for the trigger.