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

    Interface EntityInterface

    Entity interface.

    interface EntityInterface {
        $nymph: Nymph;
        cdate: number | null;
        guid: string | null;
        mdate: number | null;
        tags: string[];
        $addTag(...tags: string[]): void;
        $arraySearch(array: any[], strict?: boolean): number;
        $clearCache(): void;
        $delete(): Promise<boolean>;
        $equals(object: any): boolean;
        $getClientEnabledMethods(): string[];
        $getCurrentAcValues(): ACProperties;
        $getData(
            includeSData?: boolean,
            referenceOnlyExisting?: boolean,
        ): EntityData;
        $getGuaranteedGUID(): string;
        $getOriginalAcValues(): ACProperties;
        $getSData(): SerializedEntityData;
        $getTags(): string[];
        $getUniques(): Promise<string[]>;
        $getValidatable(): Object;
        $hasTag(...tags: string[]): boolean;
        $inArray(array: any[], strict?: boolean): boolean;
        $is(object: any): boolean;
        $jsonAcceptData(input: EntityJson, allowConflict?: boolean): void;
        $jsonAcceptPatch(patch: EntityPatch, allowConflict?: boolean): void;
        $putData(
            data: EntityData,
            sdata?: SerializedEntityData,
            source?: "server",
        ): void;
        $refresh(): Promise<boolean | 0>;
        $removeTag(...tags: string[]): void;
        $save(): Promise<boolean>;
        $toReference(existingOnly?: boolean): EntityInterface | EntityReference;
        $useSkipAc(useSkipAc: boolean): void;
        [k: string]: any;
    }

    Hierarchy (View Summary)

    Implemented by

    Indexable

    • [k: string]: any

      The object's data.

    Index

    Properties

    $nymph: Nymph

    The instance of Nymph to use for queries.

    cdate: number | null

    The creation date of the entity as a Unix timestamp in milliseconds.

    guid: string | null

    The entity's Globally Unique ID.

    This is a 12 byte number represented as a lower case HEX string (24 characters).

    mdate: number | null

    The modified date of the entity as a Unix timestamp in milliseconds.

    tags: string[]

    Array of the entity's tags.

    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.

    • Replace any referenced entities in the data with sleeping references.

      Calling this function ensures that the next time a referenced entity is accessed, it will be retrieved from the DB (unless it is in Nymph's cache).

      Returns void

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

    • Get the client enabled methods.

      Returns string[]

      The names of methods allowed to be called by the frontend with serverCall.

    • Get the current values of the AC properties.

      Returns ACProperties

      An object of AC properties.

    • Used to retrieve the data object.

      This should only be used by Nymph to save the data into storage.

      Parameters

      • OptionalincludeSData: boolean

        Whether to include the serialized data as well.

      • OptionalreferenceOnlyExisting: boolean

        Whether to only turn existing entities into references.

      Returns EntityData

      The entity's data object.

    • Get a GUID for the entity.

      If the entity has already been saved, this will just return the GUID.

      If the entity has not yet been saved, this will return a new GUID that gets held by the entity. The guid property will remain null, but this method will then always return the same GUID. When the entity is eventually saved into the database, this GUID will be used.

      Returns string

    • Get the original values of the AC properties.

      Returns ACProperties

      An object of AC properties.

    • Used to retrieve the serialized data object.

      This should only be used by Nymph to save the data object into storage.

      This method is used by Nymph to avoid unserializing data that hasn't been requested yet.

      It should always be called after getData().

      Returns SerializedEntityData

      The entity's serialized data object.

    • Get the entity's tags.

      Using this instead of accessing the tags prop directly will wake sleeping references.

      Returns string[]

      The entity's tags.

    • Get an array of strings that must be unique across the current etype.

      When you try to save another entity with any of the same unique strings, Nymph will throw an error.

      The default implementation of this method returns an empty array, meaning there are no uniqueness constraints applied to its etype.

      Returns Promise<string[]>

      Resolves to an array of entity's unique constraint strings.

    • Get an object that holds the same data as the entity.

      This provides an object that can be validated.

      Returns Object

      A pure object representation of the entity.

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

      Parameters

      • ...tags: string[]

        List of tags.

      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.

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

    • Accept JSON data from the client.

      This function uses the security protection lists:

      • $protectedTags
      • $protectedData
      • $allowlistTags
      • $allowlistData

      Parameters

      • input: EntityJson

        The input data. Please note, this will be modified (destroyed).

      • OptionalallowConflict: boolean

        Allow to accept data that is older than the current data.

      Returns void

    • Accept JSON patch from the client.

      This function uses the security protection lists:

      • $protectedTags
      • $protectedData
      • $allowlistTags
      • $allowlistData

      Parameters

      • patch: EntityPatch

        The patch data. Please note, this will be modified (destroyed).

      • OptionalallowConflict: boolean

        Allow to accept data that is older than the current data.

      Returns void

    • Used to set the data.

      This should only be used by Nymph to push the data from storage or the client.

      sdata is used by Nymph to avoid unserializing data that hasn't been requested yet.

      If source is set to "server", the data is coming from the DB or the cache. If not, assume the data is coming from the client and can't be trusted.

      Parameters

      • data: EntityData

        The data object.

      • Optionalsdata: SerializedEntityData

        The serialized data object.

      • Optionalsource: "server"

        If this is set to "server", the data is coming from the DB.

      Returns void

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

    • Remove one or more tags.

      Parameters

      • ...tags: string[]

        List of tags.

      Returns void

    • Save the object to storage.

      Returns Promise<boolean>

      True on success, false on failure.

    • Return a Nymph Entity Reference for this entity.

      If the entity hasn't been saved yet (and has no GUID), it will use the guaranteed GUID from $getGuaranteedGUID, unless existingOnly is true, then it will return the entity.

      Parameters

      • OptionalexistingOnly: boolean

        Whether to only turn existing entities into references.

      Returns EntityInterface | EntityReference

      A Nymph Entity Reference array.

    • Set whether to use "skipAc" when accessing entity references.

      Parameters

      • useSkipAc: boolean

        True or false, whether to use it.

      Returns void