kysely-replication
Version:
Replication-aware Kysely query execution
39 lines (35 loc) • 1.33 kB
TypeScript
import { KyselyPlugin, PluginTransformQueryArgs, RootOperationNode, PluginTransformResultArgs, QueryResult, UnknownRow } from 'kysely';
declare module 'kysely' {
interface QueryCreator<DB> {
/**
* Use the primary dialect for the next queries.
*/
withPrimary(): this;
/**
* Use a replica dialect for the next queries.
*
* @param replicaIndex - The index of the replica to use. If not provided, defaults to replica strategy.
*/
withReplica(replicaIndex?: number): this;
}
interface SchemaModule {
/**
* Use the primary dialect for the next queries.
*/
withPrimary(): this;
/**
* Use a replica dialect for the next queries.
*
* @param replicaIndex - The index of the replica to use. If not provided, defaults to replica strategy.
*/
withReplica(replicaIndex?: number): this;
}
}
declare class WithDialectPlugin implements KyselyPlugin {
#private;
constructor(dialect: 'primary');
constructor(dialect: 'replica', replicaIndex?: number);
transformQuery(args: PluginTransformQueryArgs): RootOperationNode;
transformResult(args: PluginTransformResultArgs): Promise<QueryResult<UnknownRow>>;
}
export { WithDialectPlugin };