prorm API Reference
    Preparing search index...

    Interface ConstraintOptions

    A table constraint: primary key, unique, check, foreign key or exclusion. Composite constraints list every participating column in fields.

    interface ConstraintOptions {
        name?: string;
        constraintName?: string;
        type: "UNIQUE" | "PRIMARY KEY" | "FOREIGN KEY" | "CHECK";
        fields?: string[];
        compositeKey?: string[];
        references?: {
            model: string;
            field: string;
            compositeKey?: string[];
            onDelete?:
                | "CASCADE"
                | "RESTRICT"
                | "SET NULL"
                | "NO ACTION"
                | "SET DEFAULT"
                | ReferentialAction;
            onUpdate?: | "CASCADE"
            | "RESTRICT"
            | "SET NULL"
            | "NO ACTION"
            | ReferentialAction;
            match?: "FULL"
            | "PARTIAL"
            | "SIMPLE";
            deferrable?:
                | "INITIALLY DEFERRED"
                | "INITIALLY IMMEDIATE"
                | "NOT DEFERRABLE";
        };
        check?: string;
        deferrable?: | "INITIALLY DEFERRED"
        | "INITIALLY IMMEDIATE"
        | "NOT DEFERRABLE";
        match?: "FULL"
        | "PARTIAL";
    }
    Index
    name?: string

    Custom constraint name (auto-generated if not provided)

    constraintName?: string

    Alias for name - custom constraint name

    type: "UNIQUE" | "PRIMARY KEY" | "FOREIGN KEY" | "CHECK"
    fields?: string[]

    Single field or array of fields for composite constraints

    compositeKey?: string[]

    Composite foreign key fields - used with compositeKey in associations

    references?: {
        model: string;
        field: string;
        compositeKey?: string[];
        onDelete?:
            | "CASCADE"
            | "RESTRICT"
            | "SET NULL"
            | "NO ACTION"
            | "SET DEFAULT"
            | ReferentialAction;
        onUpdate?: | "CASCADE"
        | "RESTRICT"
        | "SET NULL"
        | "NO ACTION"
        | ReferentialAction;
        match?: "FULL"
        | "PARTIAL"
        | "SIMPLE";
        deferrable?:
            | "INITIALLY DEFERRED"
            | "INITIALLY IMMEDIATE"
            | "NOT DEFERRABLE";
    }

    Type Declaration

    • model: string
    • field: string
    • OptionalcompositeKey?: string[]

      Composite foreign key fields on the referenced table

    • OptionalonDelete?:
          | "CASCADE"
          | "RESTRICT"
          | "SET NULL"
          | "NO ACTION"
          | "SET DEFAULT"
          | ReferentialAction
    • OptionalonUpdate?: "CASCADE" | "RESTRICT" | "SET NULL" | "NO ACTION" | ReferentialAction
    • Optionalmatch?: "FULL" | "PARTIAL" | "SIMPLE"

      PostgreSQL: match type for foreign key (FULL, PARTIAL, SIMPLE)

    • Optionaldeferrable?: "INITIALLY DEFERRED" | "INITIALLY IMMEDIATE" | "NOT DEFERRABLE"

      PostgreSQL: deferrable constraint

    check?: string
    deferrable?: "INITIALLY DEFERRED" | "INITIALLY IMMEDIATE" | "NOT DEFERRABLE"

    PostgreSQL: deferrable constraint

    match?: "FULL" | "PARTIAL"

    Foreign key match type (FULL, PARTIAL)