Skip to main content
Version: 5.9

Reference <T>

Hierarchy

  • Reference
    • LoadedReference

Index

Constructors

constructor

  • new Reference<T>(entity: T): Reference<T>
  • Type parameters

    • T

    Parameters

    • entity: T

    Returns Reference<T>

Methods

[custom]

  • [custom](depth: number): string
  • Parameters

    • depth: number

    Returns string

getEntity

  • getEntity(): T
  • Returns T

getProperty

  • getProperty<K>(prop: K): T[K]
  • Type parameters

    • K: string | number | symbol

    Parameters

    • prop: K

    Returns T[K]

isInitialized

  • isInitialized(): boolean
  • Returns boolean

load

  • load<K, P>(options?: LoadReferenceOptions<T, P>): Promise<T>
  • load<K>(prop: K): Promise<T[K]>
  • Ensures the underlying entity is loaded first (without reloading it if it already is loaded). Returns the entity.


    Type parameters

    • K: string | number | symbol = never
    • P: string = never

    Parameters

    • optionaloptions: LoadReferenceOptions<T, P>

    Returns Promise<T>

populated

  • populated(populated?: boolean): void
  • Parameters

    • optionalpopulated: boolean

    Returns void

set

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

    • entity: T | IdentifiedReference<T, PrimaryProperty<T>>

    Returns void

toJSON

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

    • rest...args: any[]

    Returns Dictionary

unwrap

  • unwrap(): T
  • Returns T

staticcreate

  • create<T, PK>(entity: T | IdentifiedReference<T, PK>): IdentifiedReference<T, PK>
  • Type parameters

    • T: object
    • PK: unknown = PrimaryProperty<T>

    Parameters

    • entity: T | IdentifiedReference<T, PK>

    Returns IdentifiedReference<T, PK>

staticcreateFromPK

  • createFromPK<T, PK>(entityType: EntityClass<T>, pk: Primary<T>, options?: { schema?: string }): IdentifiedReference<T, PK>
  • Type parameters

    • T: object
    • PK: unknown = PrimaryProperty<T>

    Parameters

    • entityType: EntityClass<T>
    • pk: Primary<T>
    • optionaloptions: { schema?: string }
      • optionalschema: string

    Returns IdentifiedReference<T, PK>

staticcreateNakedFromPK

  • createNakedFromPK<T, PK>(entityType: EntityClass<T>, pk: Primary<T>, options?: { schema?: string }): T
  • Type parameters

    • T: object
    • PK: unknown = PrimaryProperty<T>

    Parameters

    • entityType: EntityClass<T>
    • pk: Primary<T>
    • optionaloptions: { schema?: string }
      • optionalschema: string

    Returns T

staticisReference

  • isReference<T>(data: any): data is Reference<T>
  • Checks whether the argument is instance of Reference wrapper.


    Type parameters

    • T: object

    Parameters

    • data: any

    Returns data is Reference<T>

staticunwrapReference

  • unwrapReference<T>(ref: T | Reference<T>): T
  • Returns wrapped entity.


    Type parameters

    • T: object

    Parameters

    • ref: T | Reference<T>

    Returns T

staticwrapReference

  • wrapReference<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

    • T: object

    Parameters

    • entity: T | Reference<T>
    • prop: EntityProperty<T>

    Returns T | Reference<T>