Skip to main content
Version: 5.9

MariaDbConnection

Hierarchy

  • AbstractSqlConnection
    • MariaDbConnection

Index

Constructors

constructor

  • new MariaDbConnection(config: Configuration<IDatabaseDriver<Connection>>, options?: ConnectionOptions, type?: read | write): MariaDbConnection
  • Parameters

    • config: Configuration<IDatabaseDriver<Connection>>
    • optionaloptions: ConnectionOptions
    • optionaltype: read | write

    Returns MariaDbConnection

Methods

begin

  • begin(options?: { ctx?: Transaction<any, any[]>; eventBroadcaster?: TransactionEventBroadcaster; isolationLevel?: IsolationLevel; readOnly?: boolean }): Promise<Transaction<any, any[]>>
  • Parameters

    • options: { ctx?: Transaction<any, any[]>; eventBroadcaster?: TransactionEventBroadcaster; isolationLevel?: IsolationLevel; readOnly?: boolean } = {}
      • optionalctx: Transaction<any, any[]>
      • optionaleventBroadcaster: TransactionEventBroadcaster
      • optionalisolationLevel: IsolationLevel
      • optionalreadOnly: boolean

    Returns Promise<Transaction<any, any[]>>

close

  • close(force?: boolean): Promise<void>
  • Closes the database connection (aka disconnect)


    Parameters

    • optionalforce: boolean

    Returns Promise<void>

commit

  • commit(ctx: Transaction<any, any[]>, eventBroadcaster?: TransactionEventBroadcaster): Promise<void>
  • Parameters

    • ctx: Transaction<any, any[]>
    • optionaleventBroadcaster: TransactionEventBroadcaster

    Returns Promise<void>

connect

  • connect(): Promise<void>
  • Establishes connection to database


    Returns Promise<void>

execute

  • execute<T>(queryOrKnex: string | Raw<any> | QueryBuilder<any, any>, params?: unknown[], method?: get | all | run, ctx?: any): Promise<T>
  • Type parameters

    • T: QueryResult<{ id: number }> | EntityData<Partial<any>> | EntityData<Partial<any>>[] = EntityData<Partial<any>>[]

    Parameters

    • queryOrKnex: string | Raw<any> | QueryBuilder<any, any>
    • params: unknown[] = []
    • method: get | all | run = 'all'
    • optionalctx: any

    Returns Promise<T>

getClientUrl

  • getClientUrl(): string
  • Returns string

getConnectionOptions

  • getConnectionOptions(): MySqlConnectionConfig
  • Returns MySqlConnectionConfig

getDefaultClientUrl

  • getDefaultClientUrl(): string
  • Returns default client url for given driver (e.g. mongodb://127.0.0.1:27017 for mongodb)


    Returns string

getKnex

  • getKnex(): Knex<any, any[]>
  • Returns Knex<any, any[]>

getPlatform

  • getPlatform(): Platform
  • Returns Platform

isConnected

  • isConnected(): Promise<boolean>
  • Are we connected to the database


    Returns Promise<boolean>

loadFile

  • loadFile(path: string): Promise<void>
  • Execute raw SQL queries from file


    Parameters

    • path: string

    Returns Promise<void>

rollback

  • rollback(ctx: Transaction<any, any[]>, eventBroadcaster?: TransactionEventBroadcaster): Promise<void>
  • Parameters

    • ctx: Transaction<any, any[]>
    • optionaleventBroadcaster: TransactionEventBroadcaster

    Returns Promise<void>

setMetadata

  • setMetadata(metadata: MetadataStorage): void
  • Parameters

    • metadata: MetadataStorage

    Returns void

setPlatform

  • setPlatform(platform: Platform): void
  • Parameters

    • platform: Platform

    Returns void

transactional

  • transactional<T>(cb: (trx: Transaction<any, any[]>) => Promise<T>, options?: { ctx?: Transaction<any, any[]>; eventBroadcaster?: TransactionEventBroadcaster; isolationLevel?: IsolationLevel; readOnly?: boolean }): Promise<T>
  • Type parameters

    • T

    Parameters

    • cb: (trx: Transaction<any, any[]>) => Promise<T>
      • options: { ctx?: Transaction<any, any[]>; eventBroadcaster?: TransactionEventBroadcaster; isolationLevel?: IsolationLevel; readOnly?: boolean } = {}
        • optionalctx: Transaction<any, any[]>
        • optionaleventBroadcaster: TransactionEventBroadcaster
        • optionalisolationLevel: IsolationLevel
        • optionalreadOnly: boolean

      Returns Promise<T>