Skip to main content
Version: 7.0

LoadedReference <T>

A Reference<T> that is guaranteed to be loaded, providing synchronous access via $ and get().

Hierarchy

Index

Properties

$

$: NonNullable<T>

Methods

get

  • get(): NonNullable<T>
  • Returns NonNullable<T>

inheritedgetEntity

  • getEntity(): NonNullable<T>
  • Returns the underlying entity, throwing an error if the reference is not initialized.


    Returns NonNullable<T>

inheritedgetProperty

  • getProperty<K>(prop): NonNullable<T>[K]
  • Returns the value of a property on the underlying entity. Throws if the reference is not initialized.


    Parameters

    • prop: K

    Returns NonNullable<T>[K]

inheritedisInitialized

  • isInitialized(): boolean
  • Returns whether the underlying entity has been fully loaded from the database.


    Returns boolean

inheritedload

  • load<TT, P, F, E>(options): Promise<null | Loaded<TT, P, F, E>>
  • 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>>

inheritedloadOrFail

  • loadOrFail<TT, P, F, E>(options): Promise<Loaded<TT, P, F, E>>
  • 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>>

inheritedloadProperty

  • loadProperty<TT, P, K>(prop, options): Promise<Loaded<TT, P>[K]>
  • Loads the entity if needed, then returns the value of the specified property.


    Parameters

    Returns Promise<Loaded<TT, P>[K]>

inheritedpopulated

  • populated(populated): void
  • Marks the underlying entity as populated or not for serialization purposes.


    Parameters

    • optionalpopulated: boolean

    Returns void

inheritedtoJSON

  • Serializes the underlying entity to a plain JSON object.


    Parameters

    • rest...args: any[]

    Returns Dictionary

inheritedunwrap

  • unwrap(): NonNullable<T>
  • Returns the underlying entity without checking initialization state.


    Returns NonNullable<T>