Column
Column Decorator
The Column
decorator is used to describe columns in the database within your ORM system. It takes one parameter — an object of type ColumnDecoratorInterface
, which contains options for configuring the column.
Parameters of ColumnDecoratorInterface
name:
Type:
string
Description: Specifies the name of the column in the database. If not provided, the property name in the class is used.
options:
Type:
ColumnOptionsDecoratorInterface
Description: An object containing additional options for configuring the column.
Parameters of ColumnOptionsDecoratorInterface
dataType:
Type:
PostgresqlDataTypes | MysqlDataTypes
Description: Specifies the data type of the column depending on the database type (PostgreSQL or MySQL).
nullable:
Type:
boolean
Description: Defines whether the column can contain NULL values. Defaults to
false
.
length:
Type:
number
Description: Specifies the length of the data in the column. Applies to data types such as VARCHAR.
defaultValue:
Type:
string | number | boolean
Description: The default value for the column.
unique:
Type:
boolean
Description: Indicates whether the values in the column should be unique.
PostgreSQL-Specific:
check:
Type:
string
Description: Condition for a CHECK constraint. Specified only for PostgreSQL.
nameOfCheckConstraint:
Type:
string
Description: Name of the CHECK constraint. Applies only to PostgreSQL.
nullsNotDistinct:
Type:
boolean
Description: Indicates whether NULL values should be treated as distinct. Used only in PostgreSQL.
precision:
Type:
number
Description: Precision for numeric data. Applies only to PostgreSQL.
scale:
Type:
number
Description: Number of digits after the decimal point. Applies only to PostgreSQL.
MySQL-Specific:
totalNumberOfDigits:
Type:
number
Description: Total number of digits for numeric data. Applies only to MySQL.
numberOfDigitsAfterPoint:
Type:
number
Description: Number of digits after the decimal point for numeric data. Applies only to MySQL.
displayWidth:
Type:
number
Description: Display width for numeric data. Applies only to MySQL.
isUnsigned:
Type:
boolean
Description: Indicates whether the numeric data is unsigned. Applies only to MySQL.
isZerofill:
Type:
boolean
Description: Determines whether zeros should be added before the number to fill the width. Applies only to MySQL.
isAutoIncrement:
Type:
boolean
Description: Indicates whether the column should automatically increment its value for each new record. Applies only to MySQL.
Last updated