mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
working groups & messages
This commit is contained in:
1 parent
ccbc2d3b87
commit
681ce16912
25 files changed
+476
-162
No files matched your search
@@ -64,3 +64,21 @@ export function generateConnectionPool() {
|
||||
}
|
||||
|
||||
export const pool = generateConnectionPool();
|
||||
|
||||
|
||||
export async function withTransaction(queries: Promise<any>[]): Promise<any[]> {
|
||||
const connection = await pool.getConnection()
|
||||
connection.beginTransaction();
|
||||
|
||||
try {
|
||||
const results = await Promise.all(queries)
|
||||
await connection.commit()
|
||||
await connection.release()
|
||||
return results;
|
||||
} catch (err) {
|
||||
console.warn('Error when submitting queries');
|
||||
await connection.rollback()
|
||||
await connection.release()
|
||||
return Promise.reject(err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user