Entity interface.

Type Parameters

Hierarchy

  • Entity

    Implements

    Constructors

    Properties

    $data: T

    The data proxy object.

    $dataHandler: Object

    The data proxy handler.

    $dataStore: T

    The actual data store.

    $dirty: {
        [k: string]: boolean;
    } = {}

    A map of props to whether they're dirty (for patch).

    Type declaration

    • [k: string]: boolean
    $isASleepingReference: boolean = false

    Whether this instance is a sleeping reference.

    $nymph: Nymph

    The instance of Nymph to use for queries.

    $originalTags: string[] = []

    Array of the entity's original tags (for patch).

    $sleepingReference: null | EntityReference = null

    The reference to use to wake.

    $wakePromise: null | Promise<Entity<T>> = null

    A promise that resolved when the entity's data is wake.

    cdate: null | number = null

    The creation date of the entity as a high precision Unix timestamp.

    guid: null | string = null

    The entity's Globally Unique ID.

    mdate: null | number = null

    The modified date of the entity as a high precision Unix timestamp.

    tags: string[] = []

    Array of the entity's tags.

    class: string = 'Entity'

    The lookup name for this entity.

    This is used for reference arrays (and sleeping references) and server requests.

    nymph: Nymph = ...

    The instance of Nymph to use for queries.

    Methods

    • Search the array for this object and return the corresponding index.

      If strict is false, is() is used to compare. If strict is true, equals() is used.

      Parameters

      • array: any[]

        The array to search.

      • strict: boolean = false

        Whether to use stronger comparison.

      Returns number

      The index if the object is in the array, -1 if it isn't.

    • Check whether this object is in an array.

      If strict is false, is() is used to compare. If strict is true, equals() is used.

      Parameters

      • array: any[]

        The array to search.

      • strict: boolean = false

        Whether to use stronger comparison.

      Returns boolean

      True if the object is in the array, false if it isn't.

    • Refresh the object from storage. (Bypasses Nymph's cache.)

      If the object has been deleted from storage, the database cannot be reached, or a database error occurs, refresh() will return 0.

      Returns Promise<boolean | 0>

      False if the data has not been saved, 0 if it can't be refreshed, true on success.

    • Call an instance method on the server version of this entity.

      The entity's data will be sent up to the server as well, so the server's state can match the client's state. It won't be propagated into the DB, though.

      Parameters

      • method: string

        The name of the method.

      • params: Iterable<any>

        The parameters to call the method with.

      • stateless: boolean = false

        Whether the server should return, and the client update, the data in the entity after the method has run.

      Returns Promise<any>

      The value that the method on the server returned.

    • Ready this entity's data, and the data of entity's within this one's.

      Parameters

      • Optional level: number

        The number of levels deep to wake. If undefined, it will keep going until there are no more entities. (Careful of infinite loops.)

      Returns Promise<Entity<T>>

      The entity.

    • Create or retrieve a new entity instance.

      Note that this will always return an entity, even if the GUID is not found.

      Type Parameters

      Parameters

      • this: (new () => E)
          • new (): E
          • Returns E

      • Optional guid: string

        An optional GUID to retrieve.

      Returns Promise<E & EntityDataType<E>>

    • Create a new sleeping reference instance.

      Sleeping references won't retrieve their data from the server until they are readied with $wake() or a parent's $wakeAll().

      Type Parameters

      Parameters

      • this: (new () => E)
          • new (): E
          • Returns E

      • reference: EntityReference

        The Nymph Entity Reference to use to wake.

      Returns E & EntityDataType<E>

      The new instance.

    • Call a static method on the server version of this entity.

      Parameters

      • method: string

        The name of the method.

      • params: Iterable<any>

        The parameters to call the method with.

      Returns Promise<any>

      The value that the method on the server returned.

    • Call a static iterator method on the server version of this entity.

      Parameters

      • method: string

        The name of the method.

      • params: Iterable<any>

        The parameters to call the method with.

      Returns Promise<AbortableAsyncIterator<any>>

      An iterator that iterates over values that the method on the server yields.

    Generated using TypeDoc