Skip to main content

Interface: ColumnOptions

Defined in: service-core/src/decorators/PersistenceDecorators.ts:27

The set of options available when declaring a persisted column/property via the @Column decorator.

Properties​

array?​

optional array?: boolean

Defined in: service-core/src/decorators/PersistenceDecorators.ts:62

Set to true to declare an array column. Only supported by PostgreSQL and CockroachDB. (SQL only)


comment?​

optional comment?: string

Defined in: service-core/src/decorators/PersistenceDecorators.ts:68

A comment stored with the column definition, where the database supports it. (SQL only)


default?​

optional default?: string | number | boolean | (() => string) | null

Defined in: service-core/src/decorators/PersistenceDecorators.ts:49

The column's database default, used for rows inserted without a value and, importantly, to fill existing rows when synchronize adds a new NOT NULL column to a table that already has data (without a default that fails with a NOT NULL constraint failed error). A function returns a raw SQL expression, e.g. () => "CURRENT_TIMESTAMP". (SQL only; on MongoDB use a property initializer instead.)


enum?​

optional enum?: object | (string | number)[]

Defined in: service-core/src/decorators/PersistenceDecorators.ts:64

The allowed values of an enum/simple-enum column. (SQL only)


isObjectId?​

optional isObjectId?: boolean

Defined in: service-core/src/decorators/PersistenceDecorators.ts:35

Set to true if the column stores a MongoDB ObjectId value.


length?​

optional length?: string | number

Defined in: service-core/src/decorators/PersistenceDecorators.ts:51

The maximum length of a string column, e.g. varchar(255). (SQL only)


name?​

optional name?: string

Defined in: service-core/src/decorators/PersistenceDecorators.ts:29

The name of the column in the datasource. Defaults to the property name.


nullable?​

optional nullable?: boolean

Defined in: service-core/src/decorators/PersistenceDecorators.ts:31

Set to true if the column may store null/undefined values.


precision?​

optional precision?: number

Defined in: service-core/src/decorators/PersistenceDecorators.ts:58

The total number of digits stored by a decimal/numeric column. (SQL only)


primary?​

optional primary?: boolean

Defined in: service-core/src/decorators/PersistenceDecorators.ts:33

Set to true if the column is a primary key.


scale?​

optional scale?: number

Defined in: service-core/src/decorators/PersistenceDecorators.ts:60

The number of digits after the decimal point stored by a decimal/numeric column. (SQL only)


type?​

optional type?: string | Function

Defined in: service-core/src/decorators/PersistenceDecorators.ts:42

Explicitly declares the SQL column type, overriding the type that would otherwise be inferred from TypeScript's reflected property type. Required whenever the design-time type cannot be reliably inferred, such as nullable/union-typed properties (which TypeScript reflects as Object) or properties whose value is a complex/nested structure that has no direct SQL column equivalent (e.g. "simple-json").


unique?​

optional unique?: boolean

Defined in: service-core/src/decorators/PersistenceDecorators.ts:56

Set to true to enforce that every value of the column is unique. Equivalent to also applying @Unique() to the property, so it creates a unique index on both SQL and MongoDB.


unsigned?​

optional unsigned?: boolean

Defined in: service-core/src/decorators/PersistenceDecorators.ts:66

Set to true to declare a numeric column UNSIGNED. Only supported by MySQL/MariaDB. (SQL only)