-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(config): moved typeCast function into config
- Loading branch information
Showing
2 changed files
with
39 additions
and
21 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
export const resourceName = GetCurrentResourceName(); | ||
|
||
export const mysql_debug = GetConvar('mysql_debug', 'false') === 'true'; | ||
export const mysql_slow_query_warning = GetConvarInt('mysql_slow_query_warning', 200); | ||
export const mysql_connection_string = GetConvar('mysql_connection_string', ''); | ||
|
||
export const mysql_transaction_isolation_level = (() => { | ||
const query = 'SET TRANSACTION ISOLATION LEVEL'; | ||
switch (GetConvarInt('mysql_transaction_isolation_level', 2)) { | ||
case 1: | ||
return `${query} REPEATABLE READ`; | ||
case 2: | ||
return `${query} READ COMMITTED`; | ||
case 3: | ||
return `${query} READ UNCOMMITTED`; | ||
case 4: | ||
return `${query} SERIALIZABLE`; | ||
default: | ||
return `${query} READ COMMITTED`; | ||
} | ||
})(); | ||
|
||
export const typeCast = (field, next) => { | ||
switch (field.type) { | ||
case 'DATETIME': | ||
case 'DATETIME2': | ||
case 'TIMESTAMP': | ||
case 'TIMESTAMP2': | ||
case 'NEWDATE': | ||
case 'DATE': | ||
return field.type === 'DATE' ? new Date(field.string() + ' 00:00:00').getTime() : new Date(field.string()).getTime(); | ||
case 'TINY': | ||
return field.length === 1 ? field.string() === '1' : next(); | ||
case 'BIT': | ||
return field.buffer()[0] === 1; | ||
default: | ||
return next(); | ||
} | ||
}; |