Options
All
  • Public
  • Public/Protected
  • All
Menu

Contains all information about some entity's relation.

Hierarchy

  • RelationMetadata

Index

Constructors

constructor

Properties

Optional embeddedMetadata

embeddedMetadata: EmbeddedMetadata

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

entityMetadata

entityMetadata: EntityMetadata

Entity metadata of the entity where this relation is placed.

For example for @ManyToMany(type => Category) in Post, entityMetadata will be metadata of Post entity.

foreignKeys

foreignKeys: ForeignKeyMetadata[] = []

Foreign keys created for this relation.

givenInverseSidePropertyFactory

givenInverseSidePropertyFactory: PropertyTypeFactory<any>

Inverse side of the relation set by user.

Inverse side set in the relation can be either string - property name of the column on inverse side, either can be a function that accepts a map of properties with the object and returns one of them. Second approach is used to achieve type-safety.

inverseEntityMetadata

inverseEntityMetadata: EntityMetadata

Entity metadata of the entity that is targeted by this relation.

For example for @ManyToMany(type => Category) in Post, inverseEntityMetadata will be metadata of Category entity.

inverseJoinColumns

inverseJoinColumns: ColumnMetadata[] = []

Inverse join table columns. Inverse join columns are supported only for many-to-many relations and can be obtained only from owner side of the relation. From non-owner side of the relation join columns will be undefined.

Optional inverseRelation

inverseRelation: RelationMetadata

Gets the relation metadata of the inverse side of this relation.

inverseSidePropertyPath

inverseSidePropertyPath: string

Gets the property path of the inverse side of the relation.

isCascadeInsert

isCascadeInsert: boolean = false

If set to true then related objects are allowed to be inserted to the database.

isCascadeRemove

isCascadeRemove: boolean = false

If set to true then related objects are allowed to be remove from the database.

isCascadeUpdate

isCascadeUpdate: boolean = false

If set to true then related objects are allowed to be updated in the database.

isEager

isEager: boolean = false

Indicates if this relation is eagerly loaded.

isLazy

isLazy: boolean = false

Indicates if this relation is lazily loaded.

isManyToMany

isManyToMany: boolean = false

Checks if this relation's type is "many-to-many".

isManyToManyNotOwner

isManyToManyNotOwner: boolean = false

Checks if this relation's type is "many-to-many", and is NOT owner side of the relationship. Not owner side means this side of relation does not have a join table.

isManyToManyOwner

isManyToManyOwner: boolean = false

Checks if this relation's type is "many-to-many", and is owner side of the relationship. Owner side means this side of relation has a join table.

isManyToOne

isManyToOne: boolean = false

Checks if this relation's type is "many-to-one".

isNullable

isNullable: boolean = true

Indicates if relation column value can be nullable or not.

isOneToMany

isOneToMany: boolean = false

Checks if this relation's type is "one-to-many".

isOneToOne

isOneToOne: boolean = false

Checks if this relation's type is "one-to-one".

isOneToOneNotOwner

isOneToOneNotOwner: boolean = false

Checks if this relation is NOT owner side of the "one-to-one" relation. NOT owner side means this side of relation does not have a join column in the table.

isOneToOneOwner

isOneToOneOwner: boolean = false

Checks if this relation is owner side of the "one-to-one" relation. Owner side means this side of relation has a join column in the table.

isOwning

isOwning: boolean = false

Indicates if this side is an owner of this relation.

isPrimary

isPrimary: boolean = false

Indicates if this relation's column is a primary key. Can be used only for many-to-one and owner one-to-one relations.

isTreeChildren

isTreeChildren: boolean = false

Indicates if this is a children (can be only one-to-many relation) relation in the tree tables.

isTreeParent

isTreeParent: boolean = false

Indicates if this is a parent (can be only many-to-one relation) relation in the tree tables.

isWithJoinColumn

isWithJoinColumn: boolean = false

Checks if this relation has a join column (e.g. is it many-to-one or one-to-one owner side).

joinColumns

joinColumns: ColumnMetadata[] = []

Join table columns. Join columns can be obtained only from owner side of the relation. From non-owner side of the relation join columns will be empty. If this relation is a many-to-one/one-to-one then it takes join columns from the current entity. If this relation is many-to-many then it takes all owner join columns from the junction entity.

joinTableName

joinTableName: string

Join table name.

Optional junctionEntityMetadata

junctionEntityMetadata: EntityMetadata

Entity metadata of the junction table. Junction tables have their own entity metadata objects. Defined only for many-to-many relations.

Optional onDelete

onDelete: OnDeleteType

What to do with a relation on deletion of the row containing a foreign key.

persistenceEnabled

persistenceEnabled: boolean = true

Indicates if persistence is enabled for the relation. By default its enabled, but if you want to avoid any changes in the relation to be reflected in the database you can disable it. If its disabled you can only change a relation from inverse side of a relation or using relation query builder functionality. This is useful for performance optimization since its disabling avoid multiple extra queries during entity save.

propertyName

propertyName: string

Target's property name to which relation decorator is applied.

propertyPath

propertyPath: string

Gets full path to this column property (including relation 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.

relationType

relationType: RelationType

Relation type, e.g. is it one-to-one, one-to-many, many-to-one or many-to-many.

target

target: Function | string

Target entity to which this relation is applied. Target IS NOT equal to entityMetadata.target, because relation

For example for @ManyToMany(type => Category) in Post, target will be Post. If @ManyToMany(type => Category) is in Counters which is embedded into Post, target will be Counters. If @ManyToMany(type => Category) is in abstract class BaseUser which Post extends, target will be BaseUser. Target can be string if its defined in entity schema instead of class.

type

type: Function | string

Gets the property's type to which this relation is applied.

For example for @ManyToMany(type => Category) in Post, target will be Category.

Methods

build

  • build(): void
  • Builds some depend relation metadata properties. This builder method should be used only after embedded metadata tree was build.

    Returns void

buildInverseSidePropertyPath

  • buildInverseSidePropertyPath(): string
  • Builds inverse side property path based on given inverse side property factory. This builder method should be used only after properties map of the inverse entity metadata was build.

    Returns string

buildPropertyPath

  • buildPropertyPath(): string

createValueMap

  • createValueMap(value: any): any

ensureRelationIdMap

  • Ensures that given object is an entity id map. If given id is an object then it means its already id map. If given id isn't an object then it means its a value of the id column and it creates a new id map with this value and name of the primary column.

    Parameters

    • id: any

    Returns ObjectLiteral

getEntityValue

  • getEntityValue(entity: ObjectLiteral, getLazyRelationsPromiseValue?: 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 getLazyRelationsPromiseValue: boolean = false

    Returns any | undefined

getRelationIdMap

registerForeignKeys

registerJunctionEntityMetadata

  • registerJunctionEntityMetadata(junctionEntityMetadata: EntityMetadata): void
  • Registers a given junction entity metadata. This builder method can be called after junction entity metadata for the many-to-many relation was created.

    Parameters

    Returns void

setEntityValue

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

    If merge is set to true, it merges given value into currently

    Parameters

    Returns void

Generated using TypeDoc