prorm API Reference
    Preparing search index...

    Interface TriggerDefinitionInput<T>

    A trigger.

    T names the row shape when you have one, so set and the column helpers are checked against real columns rather than accepting any string.

    interface TriggerDefinitionInput<T = Record<string, unknown>> {
        name: string;
        table: TriggerTable;
        timing: "BEFORE" | "AFTER" | "INSTEAD OF" | TriggerTiming;
        event: "INSERT" | "UPDATE" | "DELETE" | "TRUNCATE" | TriggerEvent;
        body: TriggerBody;
        forEach?: "ROW" | "STATEMENT" | TriggerForEach;
        when?: string | WhereOptions;
        updateOf?: string[] | (keyof T & string)[];
    }

    Type Parameters

    • T = Record<string, unknown>

    Hierarchy (View Summary)

    Index
    name: string

    Trigger name.

    The table it fires on: a name, or the model mapped to it.

    timing: "BEFORE" | "AFTER" | "INSTEAD OF" | TriggerTiming

    When it runs.

    event: "INSERT" | "UPDATE" | "DELETE" | "TRUNCATE" | TriggerEvent

    What fires it.

    What it does.

    forEach?: "ROW" | "STATEMENT" | TriggerForEach

    Per row (default) or per statement.

    when?: string | WhereOptions

    Guard, in the usual where syntax — use NEW() / OLD() for the rows:

    when: { [NEW('status')]: … }        // not valid: keys must be strings
    when: { status: { ne: OLD('status') } } // fires only when status changed
    updateOf?: string[] | (keyof T & string)[]

    Columns an UPDATE trigger watches (UPDATE OF a, b). PostgreSQL, Oracle.