Skip to main content
Version: 6.4

Reference <T>

Hierarchy

Index

Constructors

constructor

Methods

getEntity

  • getEntity(): T
  • Returns T

getProperty

  • getProperty(prop: K): T[K]
  • Parameters

    • prop: K

    Returns T[K]

isInitialized

  • isInitialized(): boolean
  • Returns boolean

load

  • Ensures the underlying entity is loaded first (without reloading it if it already is loaded). Returns the entity. If the entity is not found in the database (e.g. it was deleted in the meantime, or currently active filters disallow loading of it) the method returns null. Use loadOrFail() if you want an error to be thrown in such a case.


    Parameters

    Returns Promise<null | Loaded<TT, P, F, E>>

loadOrFail

  • Ensures the underlying entity is loaded first (without reloading it if it already is loaded). Returns the entity or throws an error just like em.findOneOrFail() (and respects the same config options).


    Parameters

    Returns Promise<Loaded<TT, P, F, E>>

loadProperty

populated

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

    • optionalpopulated: boolean

    Returns void

toJSON

unwrap

  • unwrap(): T
  • Returns T

staticcreate

  • create(entity: T | Ref<T>): Ref<T>
  • Parameters

    • entity: T | Ref<T>

    Returns Ref<T>

staticcreateFromPK

  • createFromPK(entityType: EntityClass<T>, pk: T extends { [PrimaryKeyProp]?: PK } ? PK extends keyof T<T> ? ReadonlyPrimary<UnwrapPrimary<T<T>[PK<PK>]>> : PK extends keyof T<T>[] ? ReadonlyPrimary<PrimaryPropToType<T<T>, PK<PK>>> : PK : T extends { _id?: PK } ? string | ReadonlyPrimary<PK> : T extends { uuid?: PK } ? ReadonlyPrimary<PK> : T extends { id?: PK } ? ReadonlyPrimary<PK> : T, options?: { schema?: string }): Ref<T>
  • Parameters

    • entityType: EntityClass<T>
    • pk: T extends { [PrimaryKeyProp]?: PK } ? PK extends keyof T<T> ? ReadonlyPrimary<UnwrapPrimary<T<T>[PK<PK>]>> : PK extends keyof T<T>[] ? ReadonlyPrimary<PrimaryPropToType<T<T>, PK<PK>>> : PK : T extends { _id?: PK } ? string | ReadonlyPrimary<PK> : T extends { uuid?: PK } ? ReadonlyPrimary<PK> : T extends { id?: PK } ? ReadonlyPrimary<PK> : T
    • optionaloptions: { schema?: string }
      • optionalschema: string

    Returns Ref<T>

staticcreateNakedFromPK

  • createNakedFromPK(entityType: EntityClass<T>, pk: T extends { [PrimaryKeyProp]?: PK } ? PK extends keyof T<T> ? ReadonlyPrimary<UnwrapPrimary<T<T>[PK<PK>]>> : PK extends keyof T<T>[] ? ReadonlyPrimary<PrimaryPropToType<T<T>, PK<PK>>> : PK : T extends { _id?: PK } ? string | ReadonlyPrimary<PK> : T extends { uuid?: PK } ? ReadonlyPrimary<PK> : T extends { id?: PK } ? ReadonlyPrimary<PK> : T, options?: { schema?: string }): T
  • Parameters

    • entityType: EntityClass<T>
    • pk: T extends { [PrimaryKeyProp]?: PK } ? PK extends keyof T<T> ? ReadonlyPrimary<UnwrapPrimary<T<T>[PK<PK>]>> : PK extends keyof T<T>[] ? ReadonlyPrimary<PrimaryPropToType<T<T>, PK<PK>>> : PK : T extends { _id?: PK } ? string | ReadonlyPrimary<PK> : T extends { uuid?: PK } ? ReadonlyPrimary<PK> : T extends { id?: PK } ? ReadonlyPrimary<PK> : T
    • optionaloptions: { schema?: string }
      • optionalschema: string

    Returns T

staticisReference

  • Checks whether the argument is instance of Reference wrapper.


    Parameters

    • data: any

    Returns data is Reference<T>

staticunwrapReference

staticwrapReference