kysely-pglite
Version:
Kysely dialect for @electric-sql/pglite
39 lines • 1.13 kB
JavaScript
import { CompiledQuery, } from 'kysely';
export class PGliteDriver {
#client;
constructor(client) {
this.#client = client;
}
async acquireConnection() {
return new PGliteConnection(this.#client);
}
async beginTransaction(connection, _settings) {
await connection.executeQuery(CompiledQuery.raw('BEGIN'));
}
async commitTransaction(connection) {
await connection.executeQuery(CompiledQuery.raw('COMMIT'));
}
async rollbackTransaction(connection) {
await connection.executeQuery(CompiledQuery.raw('ROLLBACK'));
}
async destroy() {
await this.#client.close();
}
async init() { }
async releaseConnection(_connection) { }
}
class PGliteConnection {
#client;
constructor(client) {
this.#client = client;
}
async executeQuery(compiledQuery) {
return await this.#client.query(compiledQuery.sql, [
...compiledQuery.parameters,
]);
}
async *streamQuery() {
throw new Error('PGlite does not support streaming.');
}
}
//# sourceMappingURL=pglite-driver.js.map