Skip to main content
Module

x/typeorm/src/metadata/ColumnMetadata.ts>ColumnMetadata

Forked from https://github.com/typeorm/typeorm
Latest
class ColumnMetadata
import { ColumnMetadata } from "https://deno.land/x/typeorm@v0.2.23-rc10/src/metadata/ColumnMetadata.ts";

This metadata contains all information about entity's column.

Constructors

new
ColumnMetadata(options: { connection: Connection; entityMetadata: EntityMetadata; embeddedMetadata?: EmbeddedMetadata; referencedColumn?: ColumnMetadata; args: ColumnMetadataArgs; closureType?: "ancestor" | "descendant"; nestedSetLeft?: boolean; nestedSetRight?: boolean; materializedPath?: boolean; })

Properties

optional
asExpression: string

Generated column expression. Supports only in MySQL.

optional
charset: string

Defines column character set.

optional
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: string

Defines column collation.

comment: string

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

databaseName: string

Complete column name in the database including its embedded prefixes.

databaseNameWithoutPrefixes: string

Database name in the database without embedded prefixes applied.

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: any

Default database value.

optional
embeddedMetadata: EmbeddedMetadata

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

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: (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
enumName: string

Exact name of enum

optional
generatedType: "VIRTUAL" | "STORED"

Generated column type. Supports only in MySQL.

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

Specifies generation strategy if this column will use auto increment.

optional
givenDatabaseName: string

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

optional
hstoreType: "object" | "string"

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

isArray: boolean

Indicates if this column is an array.

isCreateDate: boolean

Indicates if this column contains an entity creation date.

isDiscriminator: boolean

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

isGenerated: boolean

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

isInsert: boolean

Indicates if column is inserted by default or not.

isMaterializedPath: boolean

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

isNestedSetLeft: boolean

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

isNestedSetRight: boolean

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

isNullable: boolean

Indicates if column can contain nulls or not.

isObjectId: boolean

Indicates if this column contains an object id.

isPrimary: boolean

Indicates if this column is a primary key.

isSelect: boolean

Indicates if column is selected by query builder or not.

isTreeLevel: boolean

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

isUpdate: boolean

Indicates if column allows updates or not.

isUpdateDate: boolean

Indicates if this column contains an entity update date.

isVersion: boolean

Indicates if this column contains an entity version.

isVirtual: boolean

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

length: string

Type's length in the database.

optional
onUpdate: string

ON UPDATE trigger. Works only for MySQL.

optional
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: string

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

propertyName: string

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

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: 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

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: 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: string

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

optional
srid: number

SRID (Spatial Reference ID (EPSG code))

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: ValueTransformer | ValueTransformer[]

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

The database type of the column.

unsigned: boolean

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

optional
width: number

Type's display width in the database.

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

Methods

protected
buildDatabaseName(connection: Connection): string
protected
buildDatabasePath(): string
protected
buildPropertyPath(): string
build(connection: Connection): this
createValueMap(value: any, useDatabaseName?)

Creates entity id map from the given entity ids array.

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.

getEntityValueMap(entity: ObjectLiteral, options?: { skipNulls?: boolean; }): ObjectLiteral | undefined

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 } } } }

setEntityValue(entity: ObjectLiteral, value: any): void

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