prorm API Reference
    Preparing search index...

    Interface QueryOptions

    interface QueryOptions {
        type?:
            | "SELECT"
            | "INSERT"
            | "UPDATE"
            | "DELETE"
            | "UPSERT"
            | "BULKINSERT"
            | "BULKDELETE"
            | "VERSION"
            | "SHOWTABLES"
            | "DESCRIBE"
            | "RAW"
            | QueryTypes;
        replacements?: unknown[]
        | Record<string, unknown>;
        raw?: boolean;
        logging?: boolean | ((sql: string, timing?: number) => void);
        benchmark?: boolean;
        transaction?: Transaction;
        retry?: { max: number; match?: string[] };
        mapToModel?: boolean;
        model?: ModelStatic<any>;
    }
    Index
    type?:
        | "SELECT"
        | "INSERT"
        | "UPDATE"
        | "DELETE"
        | "UPSERT"
        | "BULKINSERT"
        | "BULKDELETE"
        | "VERSION"
        | "SHOWTABLES"
        | "DESCRIBE"
        | "RAW"
        | QueryTypes

    Query type - determines how results are processed Forces the query type for result handling

    • SELECT: Returns array of rows
    • INSERT: Returns [rows, created]
    • UPDATE: Returns affected count
    • DELETE: Returns affected count
    • BULKDELETE: Returns affected count
    • UPSERT: Returns [rows, created]
    replacements?: unknown[] | Record<string, unknown>

    Replacements for named (:param) or positional (?) placeholders For named: { username: 'john' } replaces :username in SQL For positional: ['john', 'smith'] replaces ? in order

    raw?: boolean

    Return raw results without model instantiation

    logging?: boolean | ((sql: string, timing?: number) => void)

    Whether to log the query

    benchmark?: boolean

    When true, logs query execution time

    transaction?: Transaction

    Transaction to use for the query

    retry?: { max: number; match?: string[] }

    Retry configuration for query execution On connection failure or retryable errors, retry up to max times

    Maximum number of retry attempts

    Array of error message patterns that trigger retry

    // Retry on connection refused or timeout errors
    await prorm.query('SELECT * FROM users', {
    retry: { max: 3, match: ['Connection refused', 'Timeout', 'ECONNREFUSED'] }
    });
    mapToModel?: boolean

    Map raw query results to a model instance When true, maps the result rows to ModelInstance objects using the provided model

    false
    
    model?: ModelStatic<any>

    Model to use for mapping raw results to model instances Used together with mapToModel to create ModelInstance objects from raw query results