Skip to content

postgrelize / cast

Function: cast() ​

cast(val, type): Cast

Defined in: src/expressions/methods.ts:86

Creates a type cast CAST(value AS type).

Parameters ​

val ​

unknown

Value or expression to cast.

type ​

string

PostgreSQL type name, e.g. 'integer'.

Returns ​

Cast

Cast expression.

Example ​

ts
await Product.findAll({ attributes: [[cast(col('price'), 'integer'), 'rounded']] });

Released under the MIT License.