30 lines
933 B
JavaScript
30 lines
933 B
JavaScript
require("dotenv").config({ path: "./../.env" });
|
|
import grabDSQLConnection from "../utils/grab-dsql-connection";
|
|
/**
|
|
* # Main DB Handler Function
|
|
* @async
|
|
*
|
|
* @param {object} params
|
|
* @param {string} params.query
|
|
* @param {string[] | object} [params.values]
|
|
* @param {string} [params.database]
|
|
*
|
|
* @returns {Promise<object|null>}
|
|
*/
|
|
(async () => {
|
|
var _a;
|
|
const CONNECTION = grabDSQLConnection();
|
|
try {
|
|
const result = await CONNECTION.query("SELECT id,first_name,last_name FROM users LIMIT 3");
|
|
console.log("Connection Query Success =>", result);
|
|
}
|
|
catch (error) {
|
|
console.log("Connection query ERROR =>", error.message);
|
|
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Error Checking DB`, error);
|
|
}
|
|
finally {
|
|
CONNECTION === null || CONNECTION === void 0 ? void 0 : CONNECTION.end();
|
|
process.exit();
|
|
}
|
|
})();
|