Version: 4.3

Class: Reference<T>

Type parameters

NameType
TAnyEntity<T>

Hierarchy

Constructors

constructor

+ new Reference(entity: T): Reference

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

Parameters:

NameType
entityT

Returns: Reference

Properties

entity

Private entity: T

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

Methods

getEntity

getEntity(): T

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

Returns: T


getProperty

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

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

Type parameters:

NameType
Kkeyof T

Parameters:

NameType
propK

Returns: T[K]


isInitialized

isInitialized(): boolean

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

Returns: boolean


load

load(): Promise<T>

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

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

Returns: Promise<T>

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

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

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
Kkeyof T

Parameters:

NameType
propK

Returns: Promise<T[K]>


populated

populated(populated?: boolean): void

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

Parameters:

NameType
populated?boolean

Returns: void


set

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

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

Parameters:

NameType
entityT | IdentifiedReference<T>

Returns: void


toJSON

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

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

Parameters:

NameType
...argsany[]

Returns: Dictionary


unwrap

unwrap(): T

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

Returns: T


create

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

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

Type parameters:

NameTypeDefault
TAnyEntity<T>-
PKkeyof T | unknownPrimaryProperty\<T>

Parameters:

NameType
entityT | IdentifiedReference<T, PK>

Returns: IdentifiedReference<T, PK>


isReference

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

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

Checks whether the argument is instance or Reference wrapper.

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
dataany

Returns: data is Reference<T>


unwrapReference

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

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

Returns wrapped entity.

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
refT | Reference<T>

Returns: T


wrapReference

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

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

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

Last updated on by Martin Adámek