UNPKG

longcelot-sheet-db

Version:

Google Sheets-backed staging database adapter for Node.js with schema-first design

35 lines 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createMySQLAdapter = createMySQLAdapter; const dialect_1 = require("./dialect"); const sqlAdapterBase_1 = require("./sqlAdapterBase"); const lazyRequireDriver_1 = require("./lazyRequireDriver"); class MySQLConnection { constructor(pool) { this.pool = pool; } async query(text, params) { const [rows] = await this.pool.query(text, params); return { rows: rows }; } } /** * `mysql2` is an optional peer dependency, lazy-required only here — see postgresAdapter.ts's * matching comment for why (Phase 16.2). Uses the `mysql2/promise` entry point since * SQLConnection.query() is promise-based. */ function createMySQLAdapter(config) { let pool; if (config.pool) { pool = config.pool; } else { const mysqlModule = (0, lazyRequireDriver_1.lazyRequireDriver)('mysql2/promise', 'mysql2', 'createMySQLAdapter()'); pool = mysqlModule.createPool({ uri: config.connectionString ?? process.env.DATABASE_URL }); } return new sqlAdapterBase_1.SQLAdapterBase(new MySQLConnection(pool), dialect_1.MySQLDialect, { tenantColumn: config.tenantColumn, permissions: config.permissions, }); } //# sourceMappingURL=mysqlAdapter.js.map