The MySQL Nymph database driver.

Hierarchy (view full)

Constructors

Properties

connected: boolean = false
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
link: Pool
mysqlConfig: PoolOptions
nymph: Nymph
prefix: string
transaction: null | MySQLDriverTransaction = null

Methods

  • Remove all copies of an entity from the cache.

    Parameters

    • guid: string

      The GUID of the entity to remove.

    Returns void

  • Create entity tables in the database.

    Parameters

    • etype: null | string = null

      The entity type to create a table for. If this is blank, the default tables are created.

    Returns Promise<boolean>

    True on success, false on failure.

  • Parameters

    • filename: string

    Returns Promise<boolean>

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

  • Returns Promise<boolean>

  • Parameters

    • svalue: string

    Returns string[]

  • 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

    • filename: string
    • Optional transaction: boolean

    Returns Promise<boolean>

  • Parameters

    • text: string
    • Optional transaction: boolean

    Returns Promise<boolean>

  • Parameters

    • lines: Iterable<string>
    • Optional transaction: boolean

    Returns Promise<boolean>

  • Initialize the Nymph driver.

    This is meant to be called internally by Nymph. Don't call this directly.

    Parameters

    • nymph: Nymph

      The Nymph instance.

    Returns void

  • 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[]

  • Generate the MySQL query.

    Parameters

    • options: Options

      The options array.

    • formattedSelectors: FormattedSelector[]

      The formatted selector array.

    • etype: string
    • count: {
          i: number;
      } = ...

      Used to track internal params.

      • i: number
    • params: {
          [k: string]: any;
      } = {}

      Used to store internal params.

      • [k: string]: any
    • subquery: boolean = false

      Whether only a subquery should be returned.

    • tableSuffix: string = ''
    • etypes: string[] = []
    • guidSelector: undefined | string = undefined

    Returns {
        etypes: string[];
        params: {
            [k: string]: any;
        };
        query: string;
    }

    The SQL query.

    • etypes: string[]
    • params: {
          [k: string]: any;
      }
      • [k: string]: any
    • query: 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>

  • Parameters

    • pattern: string
    • subject: string
    • Optional caseInsensitive: boolean

    Returns boolean

  • Pull an entity from the cache.

    Type Parameters

    Parameters

    • guid: string

      The entity's GUID.

    • className: string

      The entity's class.

    • Optional useSkipAc: boolean

      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

  • Type Parameters

    • T extends (() => any)

    Parameters

    • runQuery: T
    • query: string
    • etypes: string[] = []

    Returns ReturnType<T>

  • Parameters

    • query: string
    • __namedParameters: {
          etypes?: string[];
          params?: {
              [k: string]: any;
          };
      } = {}
      • Optional etypes?: string[]
      • Optional params?: {
            [k: string]: any;
        }
        • [k: string]: any

    Returns Promise<any>

  • Parameters

    • query: string
    • __namedParameters: {
          etypes?: string[];
          params?: {
              [k: string]: any;
          };
      } = {}
      • Optional etypes?: string[]
      • Optional params?: {
            [k: string]: any;
        }
        • [k: string]: any

    Returns Promise<any>

  • Parameters

    • query: string
    • __namedParameters: {
          etypes?: string[];
          params?: {
              [k: string]: any;
          };
      } = {}
      • Optional etypes?: string[]
      • Optional params?: {
            [k: string]: any;
        }
        • [k: string]: any

    Returns Promise<{
        changes: any;
    }>

  • Parameters

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

    Returns Promise<boolean>

  • Parameters

    • origQuery: string
    • origParams: {
          [k: string]: any;
      }
      • [k: string]: any

    Returns {
        params: any[];
        query: string;
    }

    • params: any[]
    • query: string