Skip to main content
Version: 5.9

abstractAbstractSqlConnection

Hierarchy

  • Connection
    • AbstractSqlConnection
      • SqliteConnection
      • BetterSqliteConnection
      • MariaDbConnection
      • MySqlConnection
      • PostgreSqlConnection

Index

Constructors

constructor

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

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

    Returns AbstractSqlConnection

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>

abstractconnect

  • 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(): ConnectionConfig
  • Returns ConnectionConfig

abstractgetDefaultClientUrl

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