prorm API Reference
    Preparing search index...

    Variable CastConst

    Cast: {
        string(value: any): CastExpression;
        char(value: any, length?: number): CastExpression;
        text(value: any): CastExpression;
        integer(value: any): CastExpression;
        bigint(value: any): CastExpression;
        float(value: any): CastExpression;
        double(value: any): CastExpression;
        decimal(value: any, precision?: number, scale?: number): CastExpression;
        boolean(value: any): CastExpression;
        date(value: any): CastExpression;
        datetime(value: any): CastExpression;
        time(value: any): CastExpression;
        timestamp(value: any): CastExpression;
        json(value: any): CastExpression;
        blob(value: any): CastExpression;
        uuid(value: any): CastExpression;
        valueOf(value: any, type: string): CastExpression;
    } = ...

    Type coercion helpers for common SQL types Provides convenience methods for casting values to specific types

    Type Declaration

    import { Cast, col } from 'orm';

    // Cast.string - CAST(value AS VARCHAR)
    User.findAll({
    attributes: [[Cast.string(col('age')), 'ageStr']]
    })

    // Cast.integer - CAST(value AS INTEGER)
    User.findAll({
    attributes: [[Cast.integer(col('price')), 'priceInt']]
    })

    // Cast.date - CAST(value AS DATE)
    User.findAll({
    attributes: [[Cast.date(col('timestamp')), 'dateOnly']]
    })

    // Cast.boolean - CAST(value AS BOOLEAN)
    User.findAll({
    attributes: [[Cast.boolean(col('flag')), 'flagBool']]
    })

    // Cast.float - CAST(value AS FLOAT)
    User.findAll({
    attributes: [[Cast.float(col('amount')), 'amountFloat']]
    })

    // Cast.decimal - CAST(value AS DECIMAL)
    User.findAll({
    attributes: [[Cast.decimal(col('price'), 10, 2), 'priceDecimal']]
    })

    // Cast.json - CAST(value AS JSON)
    User.findAll({
    attributes: [[Cast.json(col('data')), 'dataJson']]
    })