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.

44 lines (43 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OracleDBPoolQueryRunner = void 0; const oracledb_1 = require("oracledb"); const OracleDBQueryRunner_1 = require("./OracleDBQueryRunner"); const PromiseBasedPoolQueryRunner_1 = require("./PromiseBasedPoolQueryRunner"); class OracleDBPoolQueryRunner extends PromiseBasedPoolQueryRunner_1.PromiseBasedPoolQueryRunner { constructor(pool) { super(); this.pool = pool; this.database = 'oracle'; } useDatabase(database) { if (database !== 'oracle') { throw new Error('Unsupported database: ' + database + '. OracleDBPoolQueryRunner only supports oracle databases'); } } getNativeRunner() { return this.pool; } addParam(params, value) { const index = params.length; params.push(value); return ':' + index; } addOutParam(params, name) { const index = params.length; if (name) { params.push({ dir: oracledb_1.BIND_OUT, as: name }); } else { params.push({ dir: oracledb_1.BIND_OUT }); } return ':' + index; } createQueryRunner() { return this.pool.getConnection().then(connection => new OracleDBQueryRunner_1.OracleDBQueryRunner(connection)); } releaseQueryRunner(queryRunner) { queryRunner.getNativeRunner().close(); } } exports.OracleDBPoolQueryRunner = OracleDBPoolQueryRunner;