41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.default = NO_DB_HANDLER;
|
|
const grab_dsql_connection_1 = __importDefault(require("../../grab-dsql-connection"));
|
|
/**
|
|
* # DSQL user read-only DB handler
|
|
*/
|
|
function NO_DB_HANDLER(...args) {
|
|
var _a;
|
|
const CONNECTION = (0, grab_dsql_connection_1.default)();
|
|
try {
|
|
return new Promise((resolve, reject) => {
|
|
CONNECTION.query(...args)
|
|
.then((results) => {
|
|
CONNECTION.end();
|
|
resolve(JSON.parse(JSON.stringify(results)));
|
|
})
|
|
.catch((err) => {
|
|
CONNECTION.end();
|
|
resolve({
|
|
error: err.message,
|
|
sql: err.sql,
|
|
});
|
|
});
|
|
});
|
|
}
|
|
catch (error) {
|
|
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `NO_DB_HANDLER Error`, error);
|
|
return {
|
|
success: false,
|
|
error: error.message,
|
|
};
|
|
}
|
|
finally {
|
|
CONNECTION === null || CONNECTION === void 0 ? void 0 : CONNECTION.end();
|
|
}
|
|
}
|