ConstCast to DECIMAL type
Optionalprecision: numberOptionalscale: numberimport { 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']]
})
Type coercion helpers for common SQL types Provides convenience methods for casting values to specific types