Nymph.js 1.0.0-beta.113
    Preparing search index...

    Entity interface.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    $data: UserData

    The data proxy object.

    $dataHandler: Object

    The data proxy handler.

    $dataStore: UserData

    The actual data store.

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

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

    $isASleepingReference: boolean

    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: EntityReference | null

    The reference to use to wake.

    $wakePromise: Promise<Entity<UserData>> | null

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

    cdate: number | null

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

    guid: string | null

    The entity's Globally Unique ID.

    mdate: number | null

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

    tags: string[]

    Array of the entity's tags.

    class: string = 'User'

    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.

    stores: WeakMap<Nymph, InstanceStore> = ...

    Methods

    • Add one or more tags.

      Parameters

      • ...tags: string[]

        List of tags.

      Returns void

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

      • Optionalstrict: boolean

        Whether to use stronger comparison.

      Returns number

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

    • Check if this is a sleeping reference.

      Returns boolean

    • Parameters

      • data: { currentPassword: string; newPassword: string; revokeCurrentTokens?: boolean }

      Returns Promise<{ message: string; result: boolean }>

    • Check if this is a sleeping reference and throw an error if so.

      Returns void

    • Returns Promise<{ message: string; result: boolean }>

    • Returns Promise<{ message: string; result: boolean }>

    • Returns Promise<{ message: string; result: boolean }>

    • Delete the object from storage.

      Returns Promise<boolean>

      True on success, false on failure.

    • Perform a more strict comparison of this object to another.

      Parameters

      • object: any

        The object to compare.

      Returns boolean

      True or false.

    • Parameters

      • Optionalability: string

      Returns Promise<boolean>

    • Returns Promise<string>

    • Returns Promise<{ qrcode: string; secret: string; uri: string }>

    • Get a patch of this entity's dirty data to be applied on the server.

      Returns EntityPatch

    • Check that the entity has all of the given tags.

      Parameters

      • ...tags: string[]

        List of tags.

      Returns boolean

      True or false.

    • Returns Promise<boolean>

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

      • Optionalstrict: boolean

        Whether to use stronger comparison.

      Returns boolean

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

    • Perform a less strict comparison of this object to another.

      Parameters

      • object: any

        The object to compare.

      Returns boolean

      True or false.

    • Check whether a property is dirty.

      To be a dirty property, it must have been set or deleted since the entity was initialized. A clean property existed on initialization and hasn't been set or deleted. An untracked property didn't exist on initialization and hasn't been set or deleted.

      Note that this doesn't necessarily mean the property has changed. It could have been set to the same value, or created and then deleted.

      Entities are initialized when they are pulled from the server or saved. This is done with the $init method.

      Parameters

      • property: string

        The name of a property.

      Returns boolean | null

      True if it's dirty, false if not, and null if it's not tracked.

    • Returns Promise<{ message: string; result: boolean }>

    • Save the object's dirty data to storage.

      Returns Promise<boolean>

      True on success, false on failure.

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

    • Parameters

      • data: { additionalData?: { [k: string]: any }; password: string }

      Returns Promise<{ loggedin: boolean; message: string; result: boolean }>

    • Remove one or more tags.

      Parameters

      • ...tags: string[]

        List of tags.

      Returns void

    • Parameters

      • Optionaldata: { code: string; password: string }

      Returns Promise<{ message: string; result: boolean }>

    • Parameters

      • data: { password: string }

      Returns Promise<{ message: string; result: boolean }>

    • Save the object to storage.

      Returns Promise<boolean>

      True on success, false on failure.

    • Parameters

      • data: { code: string; password: string; secret: string }

      Returns Promise<{ message: string; result: boolean }>

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

      • Optionalstateless: boolean

        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.

    • Parameters

      • Optionaldata: { additionalData?: { [k: string]: any } }

      Returns Promise<{ message: string; result: boolean }>

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

      Parameters

      • Optionallevel: 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<UserData>>

      The entity.

    • Parameters

      • returnObjectIfNotExist: true

      Returns Promise<
          User & UserData & {
              abilities?: string[];
              email?: string;
              group?: Group & GroupData & {
                  abilities?: string[];
                  email?: string;
                  phone?: string;
                  user?: | (
                      User & UserData & { abilities?: string[] | undefined; email?: string | undefined; phone?: string | undefined; group?: (Group & GroupData & { abilities?: string[] | undefined; email?: string | undefined; phone?: string | undefined; user?: (User & ... 1 more ... & ...) | ... 1 more ... | undefined; }) | undefined; gro...
                  )
                  | null;
              };
              groups?: (
                  Group & GroupData & {
                      abilities?: string[];
                      email?: string;
                      phone?: string;
                      user?: | (
                          User & UserData & { abilities?: string[] | undefined; email?: string | undefined; phone?: string | undefined; group?: (Group & GroupData & { abilities?: string[] | undefined; email?: string | undefined; phone?: string | undefined; user?: (User & ... 1 more ... & ...) | ... 1 more ... | undefined; }) | undefined; gro...
                      )
                      | null;
                  }
              )[];
              inheritAbilities?: boolean;
              newEmailAddress?: string;
              phone?: string;
          },
      >

    • Parameters

      • OptionalreturnObjectIfNotExist: false

      Returns Promise<
          | User & UserData & {
              abilities?: string[];
              email?: string;
              group?: Group & GroupData & {
                  abilities?: string[];
                  email?: string;
                  phone?: string;
                  user?: | (
                      User & UserData & { abilities?: string[] | undefined; email?: string | undefined; phone?: string | undefined; group?: (Group & GroupData & { abilities?: string[] | undefined; email?: string | undefined; phone?: string | undefined; user?: (User & ... 1 more ... & ...) | ... 1 more ... | undefined; }) | undefined; gro...
                  )
                  | null;
              };
              groups?: (
                  Group & GroupData & {
                      abilities?: string[];
                      email?: string;
                      phone?: string;
                      user?: | (
                          User & UserData & { abilities?: string[] | undefined; email?: string | undefined; phone?: string | undefined; group?: (Group & GroupData & { abilities?: string[] | undefined; email?: string | undefined; phone?: string | undefined; user?: (User & ... 1 more ... & ...) | ... 1 more ... | undefined; }) | undefined; gro...
                      )
                      | null;
                  }
              )[];
              inheritAbilities?: boolean;
              newEmailAddress?: string;
              phone?: string;
          }
          | null,
      >

    • 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
      • Optionalguid: string

        An optional GUID to retrieve.

      Returns Promise<E & EntityDataType<E>>

    • Parameters

      • Optionalusername: string

      Returns Promise<User & UserData>

    • Parameters

      • domain: string
      • Optionaloptions: { limit?: number; offset?: number; reverse?: boolean; sort?: string }

      Returns Promise<(User & UserData)[]>

    • Parameters

      Returns void

    • Parameters

      • data: {
            additionalData?: { [k: string]: any };
            code?: string;
            password: string;
            username: string;
        }

      Returns Promise<
          {
              message: string;
              needTOTP?: true;
              result: boolean;
              user?: User & UserData & {
                  abilities?: string[];
                  email?: string;
                  group?: Group & GroupData & {
                      abilities?: string[];
                      email?: string;
                      phone?: string;
                      user?: | (
                          User & UserData & { abilities?: string[] | undefined; email?: string | undefined; phone?: string | undefined; group?: (Group & GroupData & { abilities?: string[] | undefined; email?: string | undefined; phone?: string | undefined; user?: (User & ... 1 more ... & ...) | ... 1 more ... | undefined; }) | undefined; gro...
                      )
                      | null;
                  };
                  groups?: (
                      Group & GroupData & {
                          abilities?: (...)[];
                          email?: string;
                          phone?: string;
                          user?:
                              | (
                                  User & UserData & { abilities?: string[] | undefined; email?: string | undefined; phone?: string | undefined; group?: (Group & GroupData & { abilities?: string[] | undefined; email?: string | undefined; phone?: string | undefined; user?: (User & ... 1 more ... & ...) | ... 1 more ... | undefined; }) | undefined; gro...
                              )
                              | null;
                      }
                  )[];
                  inheritAbilities?: boolean;
                  newEmailAddress?: string;
                  phone?: string;
              };
          },
      >

    • Type Parameters

      Parameters

      Returns () => boolean

    • Parameters

      • data: { password: string; secret: string; username: string }

      Returns Promise<{ message: string; result: boolean }>

    • Parameters

      • data: { account: string; recoveryType: "username" | "password" }

      Returns Promise<{ message: string; result: boolean }>

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