Options
All
  • Public
  • Public/Protected
  • All
Menu

The MySQL Nymph database driver.

Hierarchy

  • NymphDriver
    • MySQLDriver

Index

Constructors

constructor

Properties

config

Protected connected

connected: boolean = false

Protected entityCache

entityCache: {}

Type declaration

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

Protected entityCount

entityCount: {}

Type declaration

  • [k: string]: number

Protected link

link: Pool

Private mysqlConfig

mysqlConfig: PoolConfig

Protected nymph

nymph: default

Protected prefix

prefix: string

Protected transaction

transaction: null | MySQLDriverTransaction = null

Methods

checkData

  • checkData(data: EntityData, sdata: SerializedEntityData, selectors: Selector[], guid?: null | string, tags?: null | string[]): boolean
  • Parameters

    • data: EntityData
    • sdata: SerializedEntityData
    • selectors: Selector[]
    • Optional guid: null | string
    • Optional tags: null | string[]

    Returns boolean

Protected cleanCache

  • cleanCache(guid: string): void
  • Parameters

    • guid: string

    Returns void

commit

  • commit(name: string): Promise<boolean>

connect

  • connect(): Promise<true>

Private createTables

  • createTables(etype?: null | string): boolean
  • 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 boolean

    True on success, false on failure.

deleteEntity

  • deleteEntity(entity: EntityInterface): Promise<boolean>
  • Parameters

    • entity: EntityInterface

    Returns Promise<boolean>

deleteEntityByID

  • deleteEntityByID(guid: string, className?: null | string | EntityConstructor): Promise<boolean>

deleteUID

  • deleteUID(name: string): Promise<boolean>

disconnect

  • disconnect(): Promise<false>

Protected entityReferenceSearch

  • entityReferenceSearch(value: any, entity: string | EntityInterface | (string | EntityInterface)[]): boolean
  • Parameters

    • value: any
    • entity: string | EntityInterface | (string | EntityInterface)[]

    Returns boolean

export

  • export(filename: string): Promise<boolean>
  • Parameters

    • filename: string

    Returns Promise<boolean>

Protected exportEntities

  • exportEntities(writeLine: (line: string) => void): Promise<void>

exportPrint

  • exportPrint(): Promise<boolean>
  • Returns Promise<boolean>

Protected findReferences

  • findReferences(svalue: string): string[]
  • Parameters

    • svalue: string

    Returns string[]

formatSelectors

  • formatSelectors(selectors: Selector[], options?: Options<EntityConstructor>): FormattedSelector[]
  • Parameters

    • selectors: Selector[]
    • Optional options: Options<EntityConstructor>

    Returns FormattedSelector[]

Private getConnection

  • getConnection(): Promise<PoolConnection>

Protected getEntitesRowLike

  • getEntitesRowLike<T>(options: Options<T> & { return: "guid" }, selectors: Selector[], performQueryCallback: (options: Options<T>, formattedSelectors: FormattedSelector[], etype: string) => { result: any }, rowFetchCallback: () => any, freeResultCallback: () => void, getGUIDCallback: (row: any) => string, getTagsAndDatesCallback: (row: any) => { cdate: number; mdate: number; tags: string[] }, getDataNameAndSValueCallback: (row: any) => { name: string; svalue: string }): { result: any; process: any }
  • getEntitesRowLike<T>(options: Options<T>, selectors: Selector[], performQueryCallback: (options: Options<T>, formattedSelectors: FormattedSelector[], etype: string) => { result: any }, rowFetchCallback: () => any, freeResultCallback: () => void, getGUIDCallback: (row: any) => string, getTagsAndDatesCallback: (row: any) => { cdate: number; mdate: number; tags: string[] }, getDataNameAndSValueCallback: (row: any) => { name: string; svalue: string }): { result: any; process: any }
  • Type parameters

    • T: EntityConstructor = EntityConstructor

    Parameters

    • options: Options<T> & { return: "guid" }
    • selectors: Selector[]
    • performQueryCallback: (options: Options<T>, formattedSelectors: FormattedSelector[], etype: string) => { result: any }
        • (options: Options<T>, formattedSelectors: FormattedSelector[], etype: string): { result: any }
        • Parameters

          • options: Options<T>
          • formattedSelectors: FormattedSelector[]
          • etype: string

          Returns { result: any }

          • result: any
    • rowFetchCallback: () => any
        • (): any
        • Returns any

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

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

          • row: any

          Returns string

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

          • row: any

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

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

          • row: any

          Returns { name: string; svalue: string }

          • name: string
          • svalue: string

    Returns { result: any; process: any }

    • result: any
    • process:function
      • process(): string[]
      • Returns string[]

  • Type parameters

    • T: EntityConstructor = EntityConstructor

    Parameters

    • options: Options<T>
    • selectors: Selector[]
    • performQueryCallback: (options: Options<T>, formattedSelectors: FormattedSelector[], etype: string) => { result: any }
        • (options: Options<T>, formattedSelectors: FormattedSelector[], etype: string): { result: any }
        • Parameters

          • options: Options<T>
          • formattedSelectors: FormattedSelector[]
          • etype: string

          Returns { result: any }

          • result: any
    • rowFetchCallback: () => any
        • (): any
        • Returns any

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

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

          • row: any

          Returns string

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

          • row: any

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

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

          • row: any

          Returns { name: string; svalue: string }

          • name: string
          • svalue: string

    Returns { result: any; process: any }

    • result: any
    • process:function
      • process(): ReturnType<T["factorySync"]>[]
      • Returns ReturnType<T["factorySync"]>[]

getEntities

  • getEntities<T>(options: Options<T> & { return: "guid" }, ...selectors: Selector[]): Promise<string[]>
  • getEntities<T>(options?: Options<T>, ...selectors: Selector[]): Promise<ReturnType<T["factorySync"]>[]>
  • Type parameters

    • T: EntityConstructor = EntityConstructor

    Parameters

    • options: Options<T> & { return: "guid" }
    • Rest ...selectors: Selector[]

    Returns Promise<string[]>

  • Type parameters

    • T: EntityConstructor = EntityConstructor

    Parameters

    • Optional options: Options<T>
    • Rest ...selectors: Selector[]

    Returns Promise<ReturnType<T["factorySync"]>[]>

Protected getEntitiesSync

  • getEntitiesSync<T>(options: Options<T> & { return: "guid" }, ...selectors: Selector[]): string[]
  • getEntitiesSync<T>(options?: Options<T>, ...selectors: Selector[]): ReturnType<T["factorySync"]>[]
  • Type parameters

    • T: EntityConstructor = EntityConstructor

    Parameters

    • options: Options<T> & { return: "guid" }
    • Rest ...selectors: Selector[]

    Returns string[]

  • Type parameters

    • T: EntityConstructor = EntityConstructor

    Parameters

    • Optional options: Options<T>
    • Rest ...selectors: Selector[]

    Returns ReturnType<T["factorySync"]>[]

getEntitySync

  • getEntitySync<T>(options: Options<T> & { return: "guid" }, ...selectors: Selector[]): null | string
  • getEntitySync<T>(options: Options<T>, ...selectors: Selector[]): null | ReturnType<T["factorySync"]>
  • getEntitySync<T>(options: Options<T> & { return: "guid" }, guid: string): null | string
  • getEntitySync<T>(options: Options<T>, guid: string): null | ReturnType<T["factorySync"]>
  • Type parameters

    • T: EntityConstructor = EntityConstructor

    Parameters

    • options: Options<T> & { return: "guid" }
    • Rest ...selectors: Selector[]

    Returns null | string

  • Type parameters

    • T: EntityConstructor = EntityConstructor

    Parameters

    • options: Options<T>
    • Rest ...selectors: Selector[]

    Returns null | ReturnType<T["factorySync"]>

  • Type parameters

    • T: EntityConstructor = EntityConstructor

    Parameters

    • options: Options<T> & { return: "guid" }
    • guid: string

    Returns null | string

  • Type parameters

    • T: EntityConstructor = EntityConstructor

    Parameters

    • options: Options<T>
    • guid: string

    Returns null | ReturnType<T["factorySync"]>

getUID

  • getUID(name: string): Promise<null | number>

import

  • import(filename: string): Promise<boolean>

Protected importFromFile

  • importFromFile(filename: string, saveEntityCallback: (guid: string, tags: string[], sdata: SerializedEntityData, etype: string) => Promise<void>, saveUIDCallback: (name: string, value: number) => Promise<void>, startTransactionCallback?: null | (() => Promise<void>), commitTransactionCallback?: null | (() => Promise<void>)): Promise<boolean>
  • Parameters

    • filename: string
    • saveEntityCallback: (guid: string, tags: string[], sdata: SerializedEntityData, etype: string) => Promise<void>
        • (guid: string, tags: string[], sdata: SerializedEntityData, etype: string): Promise<void>
        • Parameters

          • guid: string
          • tags: string[]
          • sdata: SerializedEntityData
          • etype: string

          Returns Promise<void>

    • saveUIDCallback: (name: string, value: number) => Promise<void>
        • (name: string, value: number): Promise<void>
        • Parameters

          • name: string
          • value: number

          Returns Promise<void>

    • Optional startTransactionCallback: null | (() => Promise<void>)
    • Optional commitTransactionCallback: null | (() => Promise<void>)

    Returns Promise<boolean>

inTransaction

  • inTransaction(): Promise<boolean>

init

  • init(nymph: default): void
  • Parameters

    • nymph: default

    Returns void

Private internalTransaction

  • internalTransaction(name: string): Promise<MySQLDriverTransaction>

isConnected

  • isConnected(): boolean

Protected iterateSelectorsForQuery

  • iterateSelectorsForQuery(selectors: FormattedSelector[], callback: (key: string, value: any, typeIsOr: boolean, typeIsNot: boolean) => string): string[]
  • Parameters

    • selectors: FormattedSelector[]
    • callback: (key: string, value: any, typeIsOr: boolean, typeIsNot: boolean) => string
        • (key: string, value: any, typeIsOr: boolean, typeIsNot: boolean): string
        • Parameters

          • key: string
          • value: any
          • typeIsOr: boolean
          • typeIsNot: boolean

          Returns string

    Returns string[]

Private makeEntityQuery

  • makeEntityQuery(options: Options<EntityConstructor>, formattedSelectors: FormattedSelector[], etype: string, count?: { i: number }, params?: {}, subquery?: boolean, tableSuffix?: string, etypes?: string[]): { etypes: string[]; params: {}; query: string }
  • Generate the MySQL query.

    Parameters

    • options: Options<EntityConstructor>

      The options array.

    • formattedSelectors: FormattedSelector[]

      The formatted selector array.

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

      Used to track internal params.

      • i: number
    • params: {} = {}

      Used to store internal params.

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

      Whether only a subquery should be returned.

    • tableSuffix: string = ''
    • etypes: string[] = []

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

    The SQL query.

    • etypes: string[]
    • params: {}
      • [k: string]: any
    • query: string

newUID

  • newUID(name: string): Promise<null | number>

Protected performQuery

  • performQuery(options: Options<EntityConstructor>, formattedSelectors: FormattedSelector[], etype: string): { result: any }

Protected performQuerySync

  • performQuerySync(options: Options<EntityConstructor>, formattedSelectors: FormattedSelector[], etype: string): { result: any }

Protected posixRegexMatch

  • posixRegexMatch(pattern: string, subject: string, caseInsensitive?: boolean): boolean
  • Parameters

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

    Returns boolean

Protected pullCache

  • pullCache<T>(guid: string, className: string, useSkipAc?: boolean): null | T
  • Type parameters

    • T: EntityInterface = EntityInterface

    Parameters

    • guid: string
    • className: string
    • Optional useSkipAc: boolean

    Returns null | T

Protected pushCache

  • pushCache(guid: string, cdate: number, mdate: number, tags: string[], data: EntityData, sdata: SerializedEntityData): void
  • Parameters

    • guid: string
    • cdate: number
    • mdate: number
    • tags: string[]
    • data: EntityData
    • sdata: SerializedEntityData

    Returns void

Private query

  • query<T>(runQuery: T, query: string, etypes?: string[]): ReturnType<T>

Private queryGet

  • queryGet(query: string, __namedParameters?: { etypes?: string[]; params?: {} }): Promise<any>

Private queryIter

  • queryIter(query: string, __namedParameters?: { etypes?: string[]; params?: {} }): Promise<any>

Private queryIterSync

  • queryIterSync(query: string, __namedParameters?: { etypes?: string[]; params?: {} }): any

Private queryRun

  • queryRun(query: string, __namedParameters?: { etypes?: string[]; params?: {} }): Promise<{ changes: any }>
  • Parameters

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

    Returns Promise<{ changes: any }>

Private queryRunSync

  • queryRunSync(query: string, __namedParameters?: { etypes?: string[]; params?: {} }): undefined | { changes: any }
  • Parameters

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

    Returns undefined | { changes: any }

Private querySync

  • querySync<T>(runQuery: T, query: string, etypes?: string[]): ReturnType<T>

renameUID

  • renameUID(oldName: string, newName: string): Promise<boolean>

rollback

  • rollback(name: string): Promise<boolean>

saveEntity

  • saveEntity(entity: EntityInterface): Promise<boolean>

Protected saveEntityRowLike

  • saveEntityRowLike(entity: EntityInterface, saveNewEntityCallback: (entity: EntityInterface, guid: string, tags: string[], data: EntityData, sdata: SerializedEntityData, cdate: number, etype: string) => Promise<boolean>, saveExistingEntityCallback: (entity: EntityInterface, guid: string, tags: string[], data: EntityData, sdata: SerializedEntityData, mdate: number, etype: string) => Promise<boolean>, startTransactionCallback?: null | (() => Promise<void>), commitTransactionCallback?: null | ((success: boolean) => Promise<boolean>)): Promise<boolean>
  • Parameters

    • entity: EntityInterface
    • saveNewEntityCallback: (entity: EntityInterface, guid: string, tags: string[], data: EntityData, sdata: SerializedEntityData, cdate: number, etype: string) => Promise<boolean>
        • (entity: EntityInterface, guid: string, tags: string[], data: EntityData, sdata: SerializedEntityData, cdate: number, etype: string): Promise<boolean>
        • Parameters

          • entity: EntityInterface
          • guid: string
          • tags: string[]
          • data: EntityData
          • sdata: SerializedEntityData
          • cdate: number
          • etype: string

          Returns Promise<boolean>

    • saveExistingEntityCallback: (entity: EntityInterface, guid: string, tags: string[], data: EntityData, sdata: SerializedEntityData, mdate: number, etype: string) => Promise<boolean>
        • (entity: EntityInterface, guid: string, tags: string[], data: EntityData, sdata: SerializedEntityData, mdate: number, etype: string): Promise<boolean>
        • Parameters

          • entity: EntityInterface
          • guid: string
          • tags: string[]
          • data: EntityData
          • sdata: SerializedEntityData
          • mdate: number
          • etype: string

          Returns Promise<boolean>

    • Optional startTransactionCallback: null | (() => Promise<void>)
    • Optional commitTransactionCallback: null | ((success: boolean) => Promise<boolean>)

    Returns Promise<boolean>

setUID

  • setUID(name: string, curUid: number): Promise<boolean>

startTransaction

  • startTransaction(name: string): Promise<default>

Private translateQuery

  • translateQuery(origQuery: string, origParams: {}): { params: any[]; query: string }

Static escape

  • escape(input: string): string

Static escapeValue

  • escapeValue(input: string): string

Generated using TypeDoc