A Nymph database driver.

Hierarchy

  • NymphDriver

    Constructors

    Properties

    entityCache: {
        [k: string]: {
            cdate: number;
            data: EntityData;
            mdate: number;
            sdata: SerializedEntityData;
            tags: string[];
        };
    } = {}

    A cache to make entity retrieval faster.

    Type declaration

    entityCount: {
        [k: string]: number;
    } = {}

    A counter for the entity cache to determine the most accessed entities.

    Type declaration

    • [k: string]: number
    nymph: Nymph = ...
    putDataCounter: number = 0

    Protect against infinite loops.

    Methods

    • Returns AsyncGenerator<{
          content: string;
          type: "entity" | "comment" | "uid";
      }, void, undefined | false>

    • Type Parameters

      Parameters

      • options: Options<T> & {
            return: "count";
        }
      • selectors: Selector[]
      • performQueryCallback: ((data) => {
            result: any;
        })
      • rowFetchCallback: (() => any)
          • (): any
          • Returns any

      • freeResultCallback: (() => void)
          • (): void
          • Returns void

      • getCountCallback: ((row) => number)
          • (row): number
          • Parameters

            • row: any

            Returns number

      • getGUIDCallback: ((row) => string)
          • (row): string
          • Parameters

            • row: any

            Returns string

      • getTagsAndDatesCallback: ((row) => {
            cdate: number;
            mdate: number;
            tags: string[];
        })
          • (row): {
                cdate: number;
                mdate: number;
                tags: string[];
            }
          • Parameters

            • row: any

            Returns {
                cdate: number;
                mdate: number;
                tags: string[];
            }

            • cdate: number
            • mdate: number
            • tags: string[]
      • getDataNameAndSValueCallback: ((row) => {
            name: string;
            svalue: string;
        })
          • (row): {
                name: string;
                svalue: string;
            }
          • Parameters

            • row: any

            Returns {
                name: string;
                svalue: string;
            }

            • name: string
            • svalue: string

      Returns {
          process: (() => number | Error);
          result: any;
      }

      • process: (() => number | Error)
          • (): number | Error
          • Returns number | Error

      • result: any
    • Type Parameters

      Parameters

      • options: Options<T> & {
            return: "guid";
        }
      • selectors: Selector[]
      • performQueryCallback: ((data) => {
            result: any;
        })
      • rowFetchCallback: (() => any)
          • (): any
          • Returns any

      • freeResultCallback: (() => void)
          • (): void
          • Returns void

      • getCountCallback: ((row) => number)
          • (row): number
          • Parameters

            • row: any

            Returns number

      • getGUIDCallback: ((row) => string)
          • (row): string
          • Parameters

            • row: any

            Returns string

      • getTagsAndDatesCallback: ((row) => {
            cdate: number;
            mdate: number;
            tags: string[];
        })
          • (row): {
                cdate: number;
                mdate: number;
                tags: string[];
            }
          • Parameters

            • row: any

            Returns {
                cdate: number;
                mdate: number;
                tags: string[];
            }

            • cdate: number
            • mdate: number
            • tags: string[]
      • getDataNameAndSValueCallback: ((row) => {
            name: string;
            svalue: string;
        })
          • (row): {
                name: string;
                svalue: string;
            }
          • Parameters

            • row: any

            Returns {
                name: string;
                svalue: string;
            }

            • name: string
            • svalue: string

      Returns {
          process: (() => Error | string[]);
          result: any;
      }

      • process: (() => Error | string[])
          • (): Error | string[]
          • Returns Error | string[]

      • result: any
    • Type Parameters

      Parameters

      • options: Options<T>
      • selectors: Selector[]
      • performQueryCallback: ((data) => {
            result: any;
        })
      • rowFetchCallback: (() => any)
          • (): any
          • Returns any

      • freeResultCallback: (() => void)
          • (): void
          • Returns void

      • getCountCallback: ((row) => number)
          • (row): number
          • Parameters

            • row: any

            Returns number

      • getGUIDCallback: ((row) => string)
          • (row): string
          • Parameters

            • row: any

            Returns string

      • getTagsAndDatesCallback: ((row) => {
            cdate: number;
            mdate: number;
            tags: string[];
        })
          • (row): {
                cdate: number;
                mdate: number;
                tags: string[];
            }
          • Parameters

            • row: any

            Returns {
                cdate: number;
                mdate: number;
                tags: string[];
            }

            • cdate: number
            • mdate: number
            • tags: string[]
      • getDataNameAndSValueCallback: ((row) => {
            name: string;
            svalue: string;
        })
          • (row): {
                name: string;
                svalue: string;
            }
          • Parameters

            • row: any

            Returns {
                name: string;
                svalue: string;
            }

            • name: string
            • svalue: string

      Returns {
          process: (() => Error | EntityInstanceType<T>[]);
          result: any;
      }

    • Parameters

      • selectors: FormattedSelector[]
      • callback: ((data) => string)
          • (data): string
          • Parameters

            • data: {
                  key: string;
                  typeIsNot: boolean;
                  typeIsOr: boolean;
                  value: any;
              }
              • key: string
              • typeIsNot: boolean
              • typeIsOr: boolean
              • value: any

            Returns string

      Returns string[]

    • Detect whether the database needs to be migrated.

      If true, the database should be exported with an old version of Nymph, then imported into a fresh database with this version.

      Returns Promise<boolean>

    • Pull an entity from the cache.

      Type Parameters

      Parameters

      • guid: string

        The entity's GUID.

      • className: string

        The entity's class.

      • useSkipAc: boolean = false

        Whether to tell the entity to use skip_ac.

      Returns null | T

      The entity or null if it's not cached.

    • Push an entity onto the cache.

      Parameters

      • guid: string

        The entity's GUID.

      • cdate: number

        The entity's cdate.

      • mdate: number

        The entity's mdate.

      • tags: string[]

        The entity's tags.

      • data: EntityData

        The entity's data.

      • sdata: SerializedEntityData

        The entity's sdata.

      Returns void

    • Parameters

      • entity: EntityInterface
      • saveNewEntityCallback: ((data) => Promise<boolean>)
      • saveExistingEntityCallback: ((data) => Promise<boolean>)
      • startTransactionCallback: null | (() => Promise<void>) = null
      • commitTransactionCallback: null | ((success) => Promise<boolean>) = null

      Returns Promise<boolean>