Skip to main content
Version: 7.2

BaseSqliteConnection

Base class for SQL database connections, built on top of Kysely.

Hierarchy

Index

Constructors

constructor

Methods

inheritedbegin

  • begin(options): Promise<ControlledTransaction<any, any>>

inheritedcheckConnection

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


    Returns Promise<{ ok: true } | { error?: Error; ok: false; reason: string }>

inheritedclose

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


    Parameters

    • optionalforce: boolean

    Returns Promise<void>

inheritedcommit

  • commit(ctx, eventBroadcaster, loggerContext): Promise<void>
  • Commits the transaction or releases the savepoint.


    Parameters

    Returns Promise<void>

connect

  • connect(options): Promise<void>
  • Establishes the database connection and runs the onConnect hook.


    Parameters

    • optionaloptions: { skipOnConnect?: boolean }
      • optionalskipOnConnect: boolean

    Returns Promise<void>

inheritedcreateKysely

  • Initializes the Kysely client from driver options or a user-provided Kysely instance.


    Returns MaybePromise<void>

createKyselyDialect

  • createKyselyDialect(options): Dialect
  • Creates a Kysely dialect instance with driver-specific configuration.


    Parameters

    Returns Dialect

inheritedensureConnection

  • ensureConnection(): Promise<void>
  • Ensure the connection exists, this is used to support lazy connect when using new MikroORM() instead of the async init method.


    Returns Promise<void>

inheritedexecute

  • execute<T>(query, params, method, ctx, loggerContext): Promise<T>
  • Executes a SQL query and returns the result based on the method: 'all' for rows, 'get' for single row, 'run' for affected count.


    Parameters

    Returns Promise<T>

inheritedexecuteDump

  • executeDump(dump): Promise<void>
  • Execute raw SQL queries, handy from running schema dump loaded from a file. This method doesn't support transactions, as opposed to orm.schema.execute(), which is used internally.


    Parameters

    • dump: string

    Returns Promise<void>

inheritedgetClient

  • Returns the underlying Kysely client, creating it synchronously if needed.


    Returns Kysely<T>

inheritedgetConnectionOptions

  • Parses and returns the resolved connection configuration (host, port, user, etc.).


    Returns ConnectionConfig

inheritedgetNativeClient

  • getNativeClient(): Promise<unknown>
  • Returns the underlying database client the connection drives — e.g. the pg pool, the better-sqlite3 database, or the PGlite instance — for vendor APIs MikroORM does not wrap. Each driver narrows the return type to its own client. Its lifecycle belongs to the ORM, so leave closing it to orm.close() unless you supplied the client yourself via driverOptions.


    Returns Promise<unknown>

inheritedgetPlatform

  • Returns the platform abstraction for this connection.


    Returns Platform

inheritedinitClient

  • initClient(): Promise<void>
  • Ensures the Kysely client is initialized, creating it asynchronously if needed.


    Returns Promise<void>

inheritedisConnected

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


    Returns Promise<boolean>

inheritedrollback

  • rollback(ctx, eventBroadcaster, loggerContext): Promise<void>
  • Rolls back the transaction or rolls back to the savepoint.


    Parameters

    Returns Promise<void>

inheritedsetMetadata

  • setMetadata(metadata): void
  • Sets the metadata storage on this connection.


    Parameters

    Returns void

inheritedsetPlatform

  • setPlatform(platform): void
  • Sets the platform abstraction on this connection.


    Parameters

    Returns void

inheritedstream

  • stream<T>(query, params, ctx, loggerContext, chunkSize): AsyncIterableIterator<T, any, any>
  • Executes a SQL query and returns an async iterable that yields results row by row.


    Parameters

    Returns AsyncIterableIterator<T, any, any>

inheritedtransactional

  • transactional<T>(cb, options): Promise<T>