Skip to main content
Version: 7.2

SqlJsConnection

In-memory SQLite connection backed by sql.js (SQLite compiled to WebAssembly).

Hierarchy

Index

Constructors

constructor

Methods

inheritedbegin

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

callRoutine

  • callRoutine<T>(routine, args, ctx): Promise<T>
  • SQLite has no procedures; functions bridge via bodyJs registered as a UDF.


    Parameters

    • routine: Routine<RoutineConfig<any>, Record<string, unknown>, void>
    • args: Record<string, unknown> = {}
    • optionalctx: any

    Returns Promise<T>

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

close

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

executeDump

  • 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

getNativeClient

  • Returns the sql.js Database backing this connection, e.g. to persist it via db.export(). It is closed together with the ORM, so do not hold on to the returned handle across orm.close().


    Returns Promise<SqlJsNativeDatabase>

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>