Skip to main content
Version: 4.5

Class: Reference<T>#

core.Reference

Type parameters#

NameType
TAnyEntity<T>

Hierarchy#

Constructors#

constructor#

+ new Reference<T>(entity: T): Reference<T>

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityT

Returns: Reference<T>

Defined in: packages/core/src/entity/Reference.ts:6

Methods#

getEntity#

getEntity(): T

Returns: T

Defined in: packages/core/src/entity/Reference.ts:108


getProperty#

getProperty<K>(prop: K): T[K]

Type parameters:#

NameType
Kstring | number | symbol

Parameters:#

NameType
propK

Returns: T[K]

Defined in: packages/core/src/entity/Reference.ts:116


isInitialized#

isInitialized(): boolean

Returns: boolean

Defined in: packages/core/src/entity/Reference.ts:120


load#

load(): Promise<T>

Ensures the underlying entity is loaded first (without reloading it if it already is loaded). Returns the entity.

Returns: Promise<T>

Defined in: packages/core/src/entity/Reference.ts:67

load<K>(prop: K): Promise<T[K]>

Ensures the underlying entity is loaded first (without reloading it if it already is loaded). Returns the requested property instead of the whole entity.

Type parameters:#

NameType
Kstring | number | symbol

Parameters:#

NameType
propK

Returns: Promise<T[K]>

Defined in: packages/core/src/entity/Reference.ts:73


populated#

populated(populated?: boolean): void

Parameters:#

NameType
populated?boolean

Returns: void

Defined in: packages/core/src/entity/Reference.ts:124


set#

set(entity: T | IdentifiedReference<T, PrimaryProperty<T>>): void

Parameters:#

NameType
entityT | IdentifiedReference<T, PrimaryProperty<T>>

Returns: void

Defined in: packages/core/src/entity/Reference.ts:91


toJSON#

toJSON(...args: any[]): Dictionary<any>

Parameters:#

NameType
...argsany[]

Returns: Dictionary<any>

Defined in: packages/core/src/entity/Reference.ts:128


unwrap#

unwrap(): T

Returns: T

Defined in: packages/core/src/entity/Reference.ts:104


create#

Staticcreate<T, PK>(entity: T | IdentifiedReference<T, PK>): IdentifiedReference<T, PK>

Type parameters:#

NameTypeDefault
TAnyEntity<T>-
PKunknownPrimaryProperty<T>

Parameters:#

NameType
entityT | IdentifiedReference<T, PK>

Returns: IdentifiedReference<T, PK>

Defined in: packages/core/src/entity/Reference.ts:30


isReference#

StaticisReference<T>(data: any): data is Reference<T>

Checks whether the argument is instance or Reference wrapper.

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
dataany

Returns: data is Reference<T>

Defined in: packages/core/src/entity/Reference.ts:41


unwrapReference#

StaticunwrapReference<T>(ref: T | Reference<T>): T

Returns wrapped entity.

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
refT | Reference<T>

Returns: T

Defined in: packages/core/src/entity/Reference.ts:59


wrapReference#

StaticwrapReference<T>(entity: T | Reference<T>, prop: EntityProperty<T>): T | Reference<T>

Wraps the entity in a Reference wrapper if the property is defined as wrappedReference.

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityT | Reference<T>
propEntityProperty<T>

Returns: T | Reference<T>

Defined in: packages/core/src/entity/Reference.ts:48

Last updated on by Renovate Bot