This interface abstracts away the details of how to compile a query into SQL and execute it. Instead of passing around all those details, SelectQueryBuilder and other classes that execute queries can just pass around and instance of QueryExecutor.

interface QueryExecutor {
    get adapter(): DialectAdapter;
    get plugins(): readonly KyselyPlugin[];
    compileQuery<R>(node, queryId): kysely.CompiledQuery<R>;
    executeQuery<R>(compiledQuery, queryId): Promise<QueryResult<R>>;
    provideConnection<T>(consumer): Promise<T>;
    stream<R>(compiledQuery, chunkSize, queryId): AsyncIterableIterator<QueryResult<R>>;
    transformQuery<T>(node, queryId): T;
    withConnectionProvider(connectionProvider): QueryExecutor;
    withPlugin(plugin): QueryExecutor;
    withPluginAtFront(plugin): QueryExecutor;
    withPlugins(plugin): QueryExecutor;
    withoutPlugins(): QueryExecutor;
}

Hierarchy (view full)

Accessors

  • get adapter(): DialectAdapter
  • Returns the adapter for the current dialect.

    Returns DialectAdapter

  • get plugins(): readonly KyselyPlugin[]
  • Returns all installed plugins.

    Returns readonly KyselyPlugin[]

Methods

  • Compiles the transformed query into SQL. You usually want to pass the output of transformQuery into this method but you can compile any query using this method.

    Type Parameters

    • R = unknown

    Parameters

    Returns kysely.CompiledQuery<R>

  • Executes a compiled query and runs the result through all plugins' transformResult method.

    Type Parameters

    • R

    Parameters

    Returns Promise<QueryResult<R>>

  • Provides a connection for the callback and takes care of disposing the connection after the callback has been run.

    Type Parameters

    • T

    Parameters

    • consumer: ((connection) => Promise<T>)

    Returns Promise<T>

  • Executes a compiled query and runs the result through all plugins' transformResult method. Results are streamead instead of loaded at once.

    Type Parameters

    • R

    Parameters

    • compiledQuery: kysely.CompiledQuery<R>
    • chunkSize: number

      How many rows should be pulled from the database at once. Supported only by the postgres driver.

    • queryId: QueryId

    Returns AsyncIterableIterator<QueryResult<R>>

  • Given the query the user has built (expressed as an operation node tree) this method runs it through all plugins' transformQuery methods and returns the result.

    Type Parameters

    Parameters

    • node: T
    • queryId: QueryId

    Returns T

  • Returns a copy of this executor with a new connection provider.

    Parameters

    Returns QueryExecutor

  • Returns a copy of this executor with a plugin added as the last plugin.

    Parameters

    Returns QueryExecutor

  • Returns a copy of this executor with a plugin added as the first plugin.

    Parameters

    Returns QueryExecutor

  • Returns a copy of this executor with a list of plugins added as the last plugins.

    Parameters

    Returns QueryExecutor

  • Returns a copy of this executor without any plugins.

    Returns QueryExecutor