This repository has been archived on 2023-11-14. You can view files and clone it, but cannot push or open issues/pull-requests.
2022-07-21 04:18:39 -04:00
|
|
|
import { connection } from './migrate';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-21 15:22:00 -04:00
|
|
|
export default async function(a: any, ...opts: any[]): Promise<any[] | null> {
|
2022-07-21 04:18:39 -04:00
|
|
|
const b64 = a.split('base64,')[1];
|
|
|
|
|
const text = Buffer.from(b64, 'base64').toString();
|
2022-07-21 15:22:00 -04:00
|
|
|
try {
|
|
|
|
|
return await new Promise((resolve, reject) => {
|
|
|
|
|
connection.query(text, [...opts], (err, results) => {
|
|
|
|
|
if(!err) return resolve(results);
|
|
|
|
|
console.error(err.errno, err.sqlMessage);
|
2022-07-22 01:45:11 -04:00
|
|
|
console.error('--- Query ---');
|
2022-07-21 15:22:00 -04:00
|
|
|
console.error(err.sql);
|
|
|
|
|
reject(err);
|
|
|
|
|
});
|
2022-07-21 04:18:39 -04:00
|
|
|
});
|
2022-07-21 15:22:00 -04:00
|
|
|
} catch(e) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2022-07-21 04:18:39 -04:00
|
|
|
// console.log(...opts)
|
|
|
|
|
}
|