node-jdbc-firebird
Version:
This package is help to use jdbc connection
55 lines (54 loc) • 2.39 kB
JavaScript
;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var IDatabase_1 = require("./IDatabase");
var DatabaseDriver = /** @class */ (function () {
function DatabaseDriver(type, config) {
var _this = this;
this.get_config = function () {
return __assign(__assign(__assign(__assign({ url: _this.get_jdbcUrl(), drivername: _this.driver.className }, (_this.config.username && { user: _this.config.username })), (_this.config.password && { password: _this.config.password })), (_this.config.minpoolsize && { minpoolsize: _this.config.minpoolsize })), (_this.config.maxpoolsize && { maxpoolsize: _this.config.maxpoolsize }));
};
this.get_query = function (tableName, type) {
if (type === void 0) { type = 'D'; }
if (IDatabase_1.QueryType.columns == type) {
return _this.driver.query.columns(tableName);
}
else {
return _this.driver.query.describe(tableName);
}
};
this.get_jdbcUrl = function () {
if (_this.config.jdbcUrl) {
return _this.config.jdbcUrl;
}
else if (_this.config.path) {
return "jdbc:".concat(_this.driver.connectionType, "://").concat(_this.config.path);
}
else {
var _a = _this.config, host = _a.host, port = _a.port, database = _a.database;
return "jdbc:".concat(_this.driver.connectionType, "://").concat(host, ":").concat(port, "/").concat(database);
}
};
this.config = config;
this.driver = IDatabase_1.db.getDriver(type);
this.driverPath = IDatabase_1.db.getJar(type);
}
DatabaseDriver.prototype.set_driver = function (driver) {
this.driver = driver;
};
DatabaseDriver.prototype.set_driver_path = function (path) {
this.driverPath = path;
};
return DatabaseDriver;
}());
exports.default = DatabaseDriver;