postgrelize / DataTypes
Variable: DataTypes ​
constDataTypes:object
Defined in: src/data-types/data-types.ts:125
Column types, API-compatible with Sequelize v6 DataTypes for PostgreSQL.
BIGINT and DECIMAL values are returned as strings (like Sequelize v6) to avoid precision loss.
Type Declaration ​
ARRAY ​
readonlyARRAY: <T>(subtype) =>ArrayType&ArrayDataType<Element<T>>
type[], e.g. DataTypes.ARRAY(DataTypes.TEXT).
Type Parameters ​
T ​
T extends DataTypeInput
Parameters ​
subtype ​
T
Returns ​
ArrayType & ArrayDataType<Element<T>>
BIGINT ​
readonlyBIGINT:CallableInteger<BigIntDataType>
BIGINT; values are returned as strings.
BIT ​
readonlyBIT:Callable<BitType, [length?:number],BitType>
BIT(length), default length 1; values are strings of 0 and 1. PostgreSQL extension.
BLOB ​
readonlyBLOB:Callable<BlobType, [size?:"tiny"|"medium"|"long"],BlobType>
BYTEA; values are Buffers.
BOOLEAN ​
readonlyBOOLEAN:Callable<ScalarType, [],AbstractDataType>
BOOLEAN.
BOX ​
readonlyBOX:GeometricType
BOX; values are [corner, corner] points (the server returns the upper right first). PostgreSQL extension.
CHAR ​
readonlyCHAR:Callable<CharType, [length?:number],CharType>
CHAR(length), default length 255.
CIDR ​
readonlyCIDR:Callable<ScalarType, [],AbstractDataType>
CIDR.
CIRCLE ​
readonlyCIRCLE:GeometricType
CIRCLE; values are { x, y, radius }. PostgreSQL extension.
CITEXT ​
readonlyCITEXT:Callable<ScalarType, [],AbstractDataType>
CITEXT (case-insensitive text, requires the citext extension).
COMPOSITE ​
readonlyCOMPOSITE: (name,fields) =>CompositeType
Composite type, e.g. DataTypes.COMPOSITE('address', { street: DataTypes.TEXT, zip: DataTypes.INTEGER }); values are objects keyed by field name. Create the type first with createSql(). PostgreSQL extension.
Parameters ​
name ​
string
fields ​
Readonly<Record<string, DataTypeInput>>
Returns ​
CompositeType
DATE ​
readonlyDATE:Callable<DateType, [fsp?:number],DateType>
TIMESTAMP WITH TIME ZONE; values are Date objects.
DATEONLY ​
readonlyDATEONLY:Callable<ScalarType, [],AbstractDataType>
DATE; values are 'YYYY-MM-DD' strings.
DECIMAL ​
readonlyDECIMAL:Callable<DecimalType, [digits?:number,scale?:number],DecimalType>
DECIMAL(precision, scale); values are returned as strings.
DOUBLE ​
readonlyDOUBLE:Callable<ScalarType, [length?:number,decimals?:number],DoubleDataType>
DOUBLE PRECISION.
DOUBLE PRECISION ​
readonlyDOUBLE PRECISION:Callable<ScalarType, [length?:number,decimals?:number],DoubleDataType>
DOUBLE PRECISION (v6 alias of DOUBLE).
ENUM ​
readonlyENUM: <T>(...args) =>EnumType&EnumDataType<T>
Enumerated values: DataTypes.ENUM('a', 'b') or DataTypes.ENUM({ values: ['a', 'b'] }).
Type Parameters ​
T ​
T extends string = string
Parameters ​
args ​
...readonly (T | readonly T[] | Readonly<{ values: readonly T[]; }>)[]
Returns ​
EnumType & EnumDataType<T>
FLOAT ​
readonlyFLOAT:Callable<FloatType, [digits?:number],FloatType>
FLOAT(precision).
GEOGRAPHY ​
readonlyGEOGRAPHY:Callable<SpatialType, [geographyType?:string,srid?:number],SpatialType>
PostGIS GEOGRAPHY(type, srid).
GEOMETRY ​
readonlyGEOMETRY:Callable<SpatialType, [geometryType?:string,srid?:number],SpatialType>
PostGIS GEOMETRY(type, srid).
HSTORE ​
readonlyHSTORE:Callable<HstoreType, [],AbstractDataType>
HSTORE (requires the hstore extension); values are objects of string (or null) values, like Sequelize v6.
INET ​
readonlyINET:Callable<ScalarType, [],AbstractDataType>
INET.
INTEGER ​
readonlyINTEGER:CallableInteger<IntegerDataType>
INTEGER.
INTERVAL ​
readonlyINTERVAL:ScalarType
INTERVAL; values are PostgreSQL interval strings (e.g. '1 day 02:00:00'). PostgreSQL extension.
JSON ​
readonlyJSON:Callable<JsonType, [],AbstractDataType>
JSON.
JSONB ​
readonlyJSONB:Callable<JsonType, [],AbstractDataType>
JSONB.
LINE ​
readonlyLINE:GeometricType
LINE (a·x + b·y + c = 0); values are { a, b, c }. PostgreSQL extension.
LSEG ​
readonlyLSEG:GeometricType
LSEG line segment; values are [start, end] points. PostgreSQL extension.
LTREE ​
readonlyLTREE:ScalarType
LTREE label path (requires the ltree extension); values are strings like 'Top.Science'. PostgreSQL extension.
MACADDR ​
readonlyMACADDR:Callable<ScalarType, [],AbstractDataType>
MACADDR.
MACADDR8 ​
readonlyMACADDR8:ScalarType
MACADDR8 (EUI-64 address). PostgreSQL extension.
MEDIUMINT ​
readonlyMEDIUMINT:CallableInteger<MediumIntegerDataType>
Mapped to INTEGER (PostgreSQL has no MEDIUMINT).
MONEY ​
readonlyMONEY:ScalarType
MONEY; values are strings formatted by the server's lc_monetary (e.g. '$12.50'); numbers are accepted on write. PostgreSQL extension.
MULTIRANGE ​
readonlyMULTIRANGE:Callable<MultirangeType, [subtype:DataTypeInput],MultirangeType>
Multirange type (PostgreSQL 14+), e.g. DataTypes.MULTIRANGE(DataTypes.INTEGER) → INT4MULTIRANGE; values are arrays of [lower, upper] ranges. PostgreSQL extension.
NOW ​
readonlyNOW:DefaultValueGenerator
Default value: current timestamp.
NUMBER ​
readonlyNUMBER:Callable<DecimalType, [digits?:number,scale?:number],DecimalType>
Alias of DECIMAL.
NUMERIC ​
readonlyNUMERIC:Callable<DecimalType, [digits?:number,scale?:number],DecimalType>
Alias of DECIMAL (v6 NUMERIC).
PATH ​
readonlyPATH:GeometricType
PATH; values are { points, closed }. PostgreSQL extension.
POINT ​
readonlyPOINT:GeometricType
POINT; values are { x, y }. PostgreSQL extension.
POLYGON ​
readonlyPOLYGON:GeometricType
POLYGON; values are arrays of { x, y } points. PostgreSQL extension.
RANGE ​
readonlyRANGE:RangeFactory
Range type, e.g. DataTypes.RANGE(DataTypes.INTEGER) → INT4RANGE.
REAL ​
readonlyREAL:Callable<ScalarType, [length?:number,decimals?:number],RealDataType>
REAL.
SMALLINT ​
readonlySMALLINT:CallableInteger<SmallIntegerDataType>
SMALLINT.
STRING ​
readonlySTRING:Callable<StringType, [length?:number],StringType>
VARCHAR(length), default length 255.
TEXT ​
readonlyTEXT:Callable<TextType, [size?:"tiny"|"medium"|"long"],TextType>
TEXT. The size argument is accepted for compatibility and ignored.
TIME ​
readonlyTIME:Callable<ScalarType, [],AbstractDataType>
TIME.
TIMESTAMP ​
readonlyTIMESTAMP:Callable<TimestampType, [fsp?:number],TimestampType>
TIMESTAMP WITHOUT TIME ZONE; values are Date objects whose local wall-clock time is the stored time. PostgreSQL extension.
TINYINT ​
readonlyTINYINT:CallableInteger<TinyIntegerDataType>
Mapped to SMALLINT (PostgreSQL has no TINYINT).
TSQUERY ​
readonlyTSQUERY:ScalarType
TSQUERY; values are full-text query strings. PostgreSQL extension.
TSVECTOR ​
readonlyTSVECTOR:Callable<ScalarType, [],AbstractDataType>
TSVECTOR.
UUID ​
readonlyUUID:Callable<ScalarType, [],AbstractDataType>
UUID.
UUIDV4 ​
readonlyUUIDV4:DefaultValueGenerator
Default value: random UUID v4 generated on the client.
VARBIT ​
readonlyVARBIT:Callable<BitType, [length?:number],BitType>
BIT VARYING(length), unlimited without a length; values are strings of 0 and 1. PostgreSQL extension.
VIRTUAL ​
readonlyVIRTUAL:VirtualFactory
Attribute that is not stored in the database (computed by getters/setters).
XML ​
readonlyXML:ScalarType
XML; values are XML text. PostgreSQL extension.
Example ​
User.init({ id: { type: DataTypes.BIGINT, primaryKey: true }, name: DataTypes.STRING(64) }, { sequelize });