UNPKG

ts-sql-query

Version:

Type-safe SQL query builder like QueryDSL or JOOQ in Java or Linq in .Net for TypeScript with MariaDB, MySql, Oracle, PostgreSql, Sqlite and SqlServer support.

32 lines (31 loc) 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PgPoolQueryRunner = void 0; const PromiseBasedPoolQueryRunner_1 = require("./PromiseBasedPoolQueryRunner"); const PgQueryRunner_1 = require("./PgQueryRunner"); class PgPoolQueryRunner extends PromiseBasedPoolQueryRunner_1.PromiseBasedPoolQueryRunner { constructor(pool) { super(); this.pool = pool; this.database = 'postgreSql'; } useDatabase(database) { if (database !== 'postgreSql') { throw new Error('Unsupported database: ' + database + '. PgPoolQueryRunner only supports postgreSql databases'); } } getNativeRunner() { return this.pool; } addParam(params, value) { params.push(value); return '$' + params.length; } createQueryRunner() { return this.pool.connect().then(connection => new PgQueryRunner_1.PgQueryRunner(connection)); } releaseQueryRunner(queryRunner) { queryRunner.getNativeRunner().release(); } } exports.PgPoolQueryRunner = PgPoolQueryRunner;