29 lines
735 B
TypeScript
29 lines
735 B
TypeScript
/**
|
|
* # Root DB handler
|
|
*/
|
|
export default function ROOT_DB_HANDLER(...args: any[]) {
|
|
const NO_DB = global.DSQL_DB_CONN;
|
|
|
|
try {
|
|
return new Promise((resolve, reject) => {
|
|
NO_DB.query(...args)
|
|
.then((results) => {
|
|
NO_DB.end();
|
|
resolve(JSON.parse(JSON.stringify(results)));
|
|
})
|
|
.catch((err) => {
|
|
NO_DB.end();
|
|
resolve({
|
|
error: err.message,
|
|
sql: err.sql,
|
|
});
|
|
});
|
|
});
|
|
} catch (error: any) {
|
|
return {
|
|
success: false,
|
|
error: error.message,
|
|
};
|
|
}
|
|
}
|