Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ColumnMetadata

This metadata contains all information about entity's column.

Hierarchy

  • ColumnMetadata

Index

Constructors

constructor

Properties

Optional asExpression

asExpression: string

Generated column expression. Supports only in MySQL.

Optional charset

charset: string

Defines column character set.

Optional closureType

closureType: "ancestor" | "descendant"

Column type in the case if this column is in the closure table. Column can be ancestor or descendant in the closure tables.

Optional collation

collation: string

Defines column collation.

comment

comment: string = ""

Column comment. This feature is not supported by all databases.

databaseName

databaseName: string

Complete column name in the database including its embedded prefixes.

databaseNameWithoutPrefixes

databaseNameWithoutPrefixes: string

Database name in the database without embedded prefixes applied.

databasePath

databasePath: string

Gets full path to this column database name (including column database name). Full path is relevant when column is used in embeds (one or multiple nested). For example it will return "counters.subcounters.likes". If property is not in embeds then it returns just database name of the column.

Optional default

default: any

Default database value.

Optional embeddedMetadata

embeddedMetadata: EmbeddedMetadata

Embedded metadata where this column metadata is. If this column is not in embed then this property value is undefined.

entityMetadata

entityMetadata: EntityMetadata

Entity metadata where this column metadata is.

For example for @Column() name: string in Post, entityMetadata will be metadata of Post entity.

Optional enum

enum: (string | number)[]

Array of possible enumerated values.

postgres and mysql store enum values as strings but we want to keep support for numeric and heterogeneous based typescript enums, so we need (string|number)[]

Optional generatedType

generatedType: "VIRTUAL" | "STORED"

Generated column type. Supports only in MySQL.

Optional generationStrategy

generationStrategy: "uuid" | "increment" | "rowid"

Specifies generation strategy if this column will use auto increment.

Optional givenDatabaseName

givenDatabaseName: string

Database name set by entity metadata builder, not yet passed naming strategy process and without embedded prefixes.

Optional hstoreType

hstoreType: "object" | "string"

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

isArray

isArray: boolean = false

Indicates if this column is an array.

isCreateDate

isCreateDate: boolean = false

Indicates if this column contains an entity creation date.

isDiscriminator

isDiscriminator: boolean = false

Indicates if column is discriminator. Discriminator columns are not mapped to the entity.

isGenerated

isGenerated: boolean = false

Indicates if this column is generated (auto increment or generated other way).

isInsert

isInsert: boolean = true

Indicates if column is inserted by default or not.

isMaterializedPath

isMaterializedPath: boolean = false

Indicates if this column is materialized path's path column. Used only in tree entities with materialized path type.

isNestedSetLeft

isNestedSetLeft: boolean = false

Indicates if this column is nested set's left column. Used only in tree entities with nested-set type.

isNestedSetRight

isNestedSetRight: boolean = false

Indicates if this column is nested set's right column. Used only in tree entities with nested-set type.

isNullable

isNullable: boolean = false

Indicates if column can contain nulls or not.

isObjectId

isObjectId: boolean = false

Indicates if this column contains an object id.

isPrimary

isPrimary: boolean = false

Indicates if this column is a primary key.

isSelect

isSelect: boolean = true

Indicates if column is selected by query builder or not.

isTreeLevel

isTreeLevel: boolean = false

Indicates if column is tree-level column. Tree-level columns are used in closure entities.

isUpdate

isUpdate: boolean = true

Indicates if column allows updates or not.

isUpdateDate

isUpdateDate: boolean = false

Indicates if this column contains an entity update date.

isVersion

isVersion: boolean = false

Indicates if this column contains an entity version.

isVirtual

isVirtual: boolean = false

Indicates if column is virtual. Virtual columns are not mapped to the entity.

length

length: string = ""

Type's length in the database.

Optional onUpdate

onUpdate: string

ON UPDATE trigger. Works only for MySQL.

Optional precision

precision: number | null

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.

propertyAliasName

propertyAliasName: string

Same as property path, but dots are replaced with '_'. Used in query builder statements.

propertyName

propertyName: string

Class's property name on which this column is applied.

propertyPath

propertyPath: string

Gets full path to this column property (including column property name). Full path is relevant when column is used in embeds (one or multiple nested). For example it will return "counters.subcounters.likes". If property is not in embeds then it returns just property name of the column.

referencedColumn

referencedColumn: ColumnMetadata | undefined

If this column is foreign key then it references some other column, and this property will contain reference to this column.

Optional relationMetadata

relationMetadata: RelationMetadata

If column is a foreign key of some relation then this relation's metadata will be there. If this column does not have a foreign key then this property value is undefined.

Optional scale

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.

Optional spatialFeatureType

spatialFeatureType: string

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

Optional srid

srid: number

SRID (Spatial Reference ID (EPSG code))

target

target: Function | string

Target class where column decorator is used. This may not be always equal to entity metadata (for example embeds or inheritance cases).

Optional transformer

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

type

The database type of the column.

unsigned

unsigned: boolean = false

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

Optional width

width: number

Type's display width in the database.

zerofill

zerofill: boolean = false

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 the column

Methods

build

Protected buildDatabaseName

  • buildDatabaseName(connection: Connection): string

Protected buildDatabasePath

  • buildDatabasePath(): string

Protected buildPropertyPath

  • buildPropertyPath(): string

createValueMap

  • createValueMap(value: any, useDatabaseName?: boolean): any
  • Creates entity id map from the given entity ids array.

    Parameters

    • value: any
    • Default value useDatabaseName: boolean = false

    Returns any

getEntityValue

  • getEntityValue(entity: ObjectLiteral, transform?: boolean): any | undefined
  • Extracts column value from the given entity. If column is in embedded (or recursive embedded) it extracts its value from there.

    Parameters

    • entity: ObjectLiteral
    • Default value transform: boolean = false

    Returns any | undefined

getEntityValueMap

  • Extracts column value and returns its column name with this value in a literal object. If column is in embedded (or recursive embedded) it returns complex literal object.

    Examples what this method can return depend if this column is in embeds. { id: 1 } or { title: "hello" }, { counters: { code: 1 } }, { data: { information: { counters: { code: 1 } } } }

    Parameters

    • entity: ObjectLiteral
    • Optional options: object
      • Optional skipNulls?: boolean

    Returns ObjectLiteral | undefined

setEntityValue

  • Sets given entity's column value. Using of this method helps to set entity relation's value of the lazy and non-lazy relations.

    Parameters

    Returns void

Generated using TypeDoc