feat: Added transactions support (#20)

* feat: transactions

* Adds transactions function
* Adds query & param parser with ghmattimysql compatability

* feat: transaction exports

* Adds exports for using transactions

* feat: set transaction isolation level on start

* feat: accept mysql-async syntax

* fix: acquire connection from pool

* refactor: syntactic sugar in transaction.js

* feat: optional error logging

* It ain't pretty but it gets the job done.

* Revert "feat: optional error logging"

This reverts commit fdff479f34b7575c240334cff0f4f12d03e0d48f.

* feat: transaction isolation level convar

* fix: requested changes
This commit is contained in:
darksaid98 authored and GitHub committed 2021-09-20 16:48:24 +02:00
1 parent 5e89d62688
commit faae020dd4
6 files changed
+117 -7

No files matched your search

+21 -1
View File
@@ -15,4 +15,24 @@ if (Object.keys(config).length === 0)
const slowQueryWarning = GetConvarInt('mysql_slow_query_warning', 100);
const debug = GetConvar('mysql_debug', 'false') === 'true';
export { config, slowQueryWarning, debug };
let isolationLevel;
switch (GetConvarInt('mysql_transaction_isolation_level', 2)) {
case 1:
isolationLevel = 'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ';
break;
case 2:
isolationLevel = 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED';
break;
case 3:
isolationLevel = 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED';
break;
case 4:
isolationLevel = 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE';
break;
default:
break;
};
const resourceName = GetCurrentResourceName() || 'oxmysql';
export { config, slowQueryWarning, debug, isolationLevel, resourceName };