The trigger name in the database.
When the trigger fires relative to the DML event.
Prefer TriggerTiming: TriggerTiming.Before.
The DML event that activates the trigger.
Prefer TriggerEvent: TriggerEvent.Update.
What the trigger does — actions rather than SQL:
body: { set: { updatedAt: fn('CURRENT_TIMESTAMP') } }
body: [{ insertInto: AuditLog, values: { userId: NEW('id') } }]
A raw SQL string is still accepted for anything the actions do not cover.
OptionalforRow-level or statement-level (default: row).
Prefer TriggerForEach: TriggerForEach.Statement.
OptionaltableThe table the trigger fires on: a name or the model itself. Defaults to the table of the model the decorator is applied to.
OptionalwhenGuard, in the usual where syntax, with NEW() / OLD() for the rows:
when: { status: { ne: OLD('status') } }.
OptionalupdateColumns an UPDATE trigger watches. PostgreSQL and Oracle.
@Triggerclass decorator — declare a database trigger on a model class.Stores trigger metadata using plain class properties (no reflect-metadata dependency) consistent with the rest of this decorator suite.
Example: