API 参考
    正在准备搜索索引...

    Describes all column's options.

    interface ColumnOptions {
        array?: boolean;
        asExpression?: string;
        charset?: string;
        collation?: string;
        comment?: string;
        default?: any;
        enum?: Object | (string | number)[];
        enumName?: string;
        foreignKeyConstraintName?: string;
        generated?: boolean | "uuid" | "rowid" | "increment" | "identity";
        generatedIdentity?: "ALWAYS" | "BY DEFAULT";
        generatedType?: "VIRTUAL" | "STORED";
        hstoreType?: "string" | "object";
        insert?: boolean;
        length?: string | number;
        name?: string;
        nullable?: boolean;
        onUpdate?: string;
        precision?: null | number;
        primary?: boolean;
        primaryKeyConstraintName?: string;
        readonly?: boolean;
        scale?: number;
        select?: boolean;
        spatialFeatureType?: string;
        srid?: number;
        transformer?: ValueTransformer | ValueTransformer[];
        type?: ColumnType;
        unique?: boolean;
        unsigned?: boolean;
        update?: boolean;
        width?: number;
        zerofill?: boolean;
    }

    层级

    • ColumnCommonOptions
      • ColumnOptions
    索引

    属性

    array?: boolean

    Indicates if this column is an array. Can be simply set to true or array length can be specified. Supported only by postgres.

    asExpression?: string

    Generated column expression.

    charset?: string

    Defines a column character set. Not supported by all database types.

    collation?: string

    Defines a column collation.

    comment?: string

    Column comment. Not supported by all database types.

    default?: any

    Default database value.

    enum?: Object | (string | number)[]

    Array of possible enumerated values.

    enumName?: string

    Exact name of enum

    foreignKeyConstraintName?: string

    If this column is foreign key then this specifies the name for it.

    generated?: boolean | "uuid" | "rowid" | "increment" | "identity"

    Specifies if this column will use auto increment (sequence, generated identity, rowid). Note that in some databases only one column in entity can be marked as generated, and it must be a primary column.

    generatedIdentity?: "ALWAYS" | "BY DEFAULT"

    Identity column type. Supports only in Postgres 10+.

    generatedType?: "VIRTUAL" | "STORED"

    Generated column type.

    hstoreType?: "string" | "object"

    Return type of HSTORE column. Returns value as string or as object.

    insert?: boolean

    Indicates if column is inserted by default. Default value is "true".

    length?: string | number

    Column type's length. Used only on some column types. For example type = "string" and length = "100" means that ORM will create a column with type varchar(100).

    name?: string

    Column name in the database.

    nullable?: boolean

    Indicates if column's value can be set to NULL. Default value is "false".

    onUpdate?: string

    ON UPDATE trigger. Works only for MySQL.

    precision?: null | number

    The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum number of digits that are stored for the values.

    primary?: boolean

    Indicates if this column is a primary key. Same can be achieved when

    decorator is used.

    primaryKeyConstraintName?: string

    If this column is primary key then this specifies the name for it.

    readonly?: boolean

    Indicates if column value is not updated by "save" operation. It means you'll be able to write this value only when you first time insert the object. Default value is "false".

    Please use the update option instead. Careful, it takes the opposite value to readonly.

    scale?: number

    The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number of digits to the right of the decimal point and must not be greater than precision.

    select?: boolean

    Indicates if column is always selected by QueryBuilder and find operations. Default value is "true".

    spatialFeatureType?: string

    Spatial Feature Type (Geometry, Point, Polygon, etc.)

    srid?: number

    SRID (Spatial Reference ID (EPSG code))

    Specifies a value transformer that is to be used to (un)marshal this column when reading or writing to the database.

    type?: ColumnType

    Column type. Must be one of the value from the ColumnTypes class.

    unique?: boolean

    Specifies if column's value must be unique or not.

    unsigned?: boolean

    Puts UNSIGNED attribute on to numeric column. Works only for MySQL.

    update?: boolean

    Indicates if column value is updated by "save" operation. If false, you'll be able to write this value only when you first time insert the object. Default value is "true".

    width?: number

    Column type's display width. Used only on some column types in MySQL. For example, INT(4) specifies an INT with a display width of four digits.

    zerofill?: boolean

    Puts ZEROFILL attribute on to numeric column. Works only for MySQL. If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to this column