dsql-admin/dsql-app/package-shared/utils/backend/global-db/ROOT_DB_HANDLER.ts
Benjamin Toby e0a030f10d Updates
2025-01-13 09:00:21 +01:00

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,
};
}
}