Skip to content

postgrelize / Column

Function: Column() ​

Column(input): ModelPropertyDecorator

Defined in: src/decorators/column-decorators.ts:31

Declares a class field as a model attribute (a column).

The type is not inferred from the TypeScript type (there is no reflect-metadata): pass a DataTypes value or an options object with type. Combine with the shortcut decorators.

Parameters ​

input ​

ColumnInput

A data type (DataTypes.STRING(64)) or column options ({ type, allowNull, … }).

Returns ​

ModelPropertyDecorator

An attribute decorator. Accepts the TC39 and the legacy experimentalDecorators call signature.

Example ​

ts
class User extends Model {
  @Column({ type: DataTypes.STRING, allowNull: false })
  name!: string;
}

Released under the MIT License.