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.

37 lines (36 loc) 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PgQueryRunner = void 0; const PromiseBasedWithSqlTransactionQueryRunner_1 = require("./PromiseBasedWithSqlTransactionQueryRunner"); class PgQueryRunner extends PromiseBasedWithSqlTransactionQueryRunner_1.PromiseBasedWithSqlTransactionQueryRunner { constructor(connection) { super(); this.connection = connection; this.database = 'postgreSql'; } useDatabase(database) { if (database !== 'postgreSql') { throw new Error('Unsupported database: ' + database + '. PgQueryRunner only supports postgreSql databases'); } } getNativeRunner() { return this.connection; } getCurrentNativeTransaction() { return undefined; } execute(fn) { return fn(this.connection); } executeQueryReturning(query, params) { return this.connection.query(query, params).then((result) => result.rows); } executeMutation(query, params) { return this.connection.query(query, params).then((result) => result.rowCount); } addParam(params, value) { params.push(value); return '$' + params.length; } } exports.PgQueryRunner = PgQueryRunner;