mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 06:28:54 +00:00
refactor(transaction): individual transaction logging
I should bother patching mysql2 types, but idc
This commit is contained in:
1 parent
6c8934f906
commit
7b01898959
1 file changed
+6
-5
@@ -22,16 +22,17 @@ export const rawTransaction = async (
|
||||
let response = false;
|
||||
|
||||
try {
|
||||
const executionTime = process.hrtime();
|
||||
|
||||
await connection.beginTransaction();
|
||||
|
||||
for (const transaction of transactions) await connection.query(transaction.query, transaction.params);
|
||||
for (const transaction of transactions) {
|
||||
//@ts-expect-error
|
||||
const [result, fields, executionTime] = await connection.query(transaction.query, transaction.params);
|
||||
//@ts-expect-error
|
||||
logQuery(invokingResource, transaction.query, executionTime, transaction.params);
|
||||
}
|
||||
|
||||
await connection.commit();
|
||||
|
||||
logQuery(invokingResource, 'TRANSACTION', process.hrtime(executionTime)[1] / 1e6, parameters);
|
||||
|
||||
response = true;
|
||||
} catch (e) {
|
||||
await connection.rollback();
|
||||
|
||||
Reference in new issue
Block a user