UNPKG

godot-sqlite-kysely

Version:

Kysely dialect for godot-sqlite. Adds SQLite support to Godot/GodotJS.

47 lines (46 loc) 1.56 kB
import { GodotSQLiteKyselyWorkerConnection } from './GodotSQLiteKyselyWorkerConnection'; import { GodotSQLiteKyselySyncConnection } from './GodotSQLiteKyselySyncConnection'; import { createSQLiteConnection } from './utils'; export class GodotSQLiteKyselyDriver { #config; #connection; constructor(config) { this.#config = config; } async init() { } async acquireConnection() { let connection = this.#connection; if (!connection) { const config = this.#config; if (config.connection) { connection = new GodotSQLiteKyselySyncConnection(config.connection); } else { connection = config.workerModule ? new GodotSQLiteKyselyWorkerConnection(config, config.workerModule) : new GodotSQLiteKyselySyncConnection(createSQLiteConnection(config)); } this.#connection = connection; } return connection; } async releaseConnection(_connection) { // Not implemented. No pooling. } beginTransaction(connection, _settings) { return connection.beginTransaction(); } commitTransaction(connection) { return connection.commitTransaction(); } rollbackTransaction(connection) { return connection.rollbackTransaction(); } async destroy() { if (!this.#connection || this.#config.connection) { return; } this.#connection.close(); this.#connection = undefined; } }