Data Object interface.

Objects which hold data from some type of storage.

interface DataObjectInterface {
    $arraySearch(array, strict?): number;
    $delete(): Promise<boolean>;
    $equals(object): boolean;
    $inArray(array, strict?): boolean;
    $is(object): boolean;
    $patch(): Promise<boolean>;
    $refresh(): Promise<boolean | 0>;
    $save(): Promise<boolean>;
    [k: string]: any;
}

Hierarchy (view full)

Indexable

[k: string]: any

The object's data.

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.

    • Optional strict: boolean

      Whether to use stronger comparison.

    Returns number

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

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

    Parameters

    • object: any

      The object to compare.

    Returns boolean

    True or false.

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

    • Optional strict: 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.

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