mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-03 22:20:56 +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;
|
let response = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const executionTime = process.hrtime();
|
|
||||||
|
|
||||||
await connection.beginTransaction();
|
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();
|
await connection.commit();
|
||||||
|
|
||||||
logQuery(invokingResource, 'TRANSACTION', process.hrtime(executionTime)[1] / 1e6, parameters);
|
|
||||||
|
|
||||||
response = true;
|
response = true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await connection.rollback();
|
await connection.rollback();
|
||||||
|
|||||||
Reference in new issue
Block a user