Skip to main content
Version: 6.3

PostgreSqlConnection

Hierarchy

Index

Constructors

constructor

Methods

begin

checkConnection

  • checkConnection(): Promise<{ error?: Error; ok: boolean; reason?: string }>
  • Are we connected to the database


    Returns Promise<{ error?: Error; ok: boolean; reason?: string }>

close

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


    Parameters

    • optionalforce: boolean

    Returns Promise<void>

commit

  • Parameters

    Returns Promise<void>

connect

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


    Returns void | Promise<void>

createKnex

  • createKnex(): void
  • Returns void

ensureConnection

  • ensureConnection(): Promise<void>
  • Ensure the connection exists, this is used to support lazy connect when using MikroORM.initSync()


    Returns Promise<void>

execute

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

    Parameters

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

    Returns Promise<T>

getClientUrl

  • getClientUrl(): string
  • Returns string

getConnectionOptions

  • getConnectionOptions(): PgConnectionConfig
  • Returns PgConnectionConfig

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

  • 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

  • Parameters

    Returns Promise<void>

setMetadata

  • Parameters

    Returns void

setPlatform

  • Parameters

    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

    Returns Promise<T>