prorm API Reference
    Preparing search index...

    Interface AssociationOptions

    Shared options for every association: the alias it is exposed under, the foreign key, and what happens to children when the parent goes.

    interface AssociationOptions {
        as?: string;
        foreignKey?: string | string[] | AssociationForeignKeyOptions;
        sourceKey?: string | string[];
        targetKey?: string | string[];
        constraints?: boolean;
        onDelete?:
            | "CASCADE"
            | "RESTRICT"
            | "SET NULL"
            | "NO ACTION"
            | "SET DEFAULT"
            | ReferentialAction;
        onUpdate?: | "CASCADE"
        | "RESTRICT"
        | "SET NULL"
        | "NO ACTION"
        | "SET DEFAULT"
        | ReferentialAction;
        foreignKeyConstraint?: boolean;
        through?: string
        | ThroughOptions;
        scope?: AssociationScope;
    }
    Index
    as?: string
    foreignKey?: string | string[] | AssociationForeignKeyOptions

    Foreign key field name(s) for the association. Can be a single string for simple foreign keys, or an array for composite foreign keys.

    foreignKey: 'userId'  // Simple FK
    foreignKey: ['orderId', 'customerId'] // Composite FK
    sourceKey?: string | string[]

    Source key(s) on the source model (the model defining the association). Defaults to the primary key.

    sourceKey: 'id'  // Simple key
    sourceKey: ['id', 'tenantId'] // Composite key
    targetKey?: string | string[]

    Target key(s) on the target model (the model being associated). Defaults to the primary key.

    targetKey: 'id'  // Simple key
    targetKey: ['id', 'customerId'] // Composite key
    constraints?: boolean
    onDelete?:
        | "CASCADE"
        | "RESTRICT"
        | "SET NULL"
        | "NO ACTION"
        | "SET DEFAULT"
        | ReferentialAction

    Referential action to take when the referenced row is deleted.

    onDelete: ReferentialAction.Cascade // or onDelete: 'CASCADE'
    
    onUpdate?:
        | "CASCADE"
        | "RESTRICT"
        | "SET NULL"
        | "NO ACTION"
        | "SET DEFAULT"
        | ReferentialAction

    Referential action to take when the referenced row's key is updated.

    onUpdate: ReferentialAction.Cascade // or onUpdate: 'CASCADE'
    
    foreignKeyConstraint?: boolean
    through?: string | ThroughOptions