mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-01 22:21:51 +00:00
fix: JS sync exports check
Since JS is such a bad language it throws an error when doing `variable !== undefined`, so wrap the whole thing in a try block and catch the error.
This commit is contained in:
1 parent
94fe76340e
commit
87a5123117
3 files changed
+46
-38
No files matched your search
+2
-1
@@ -3,13 +3,14 @@ game 'common'
|
||||
|
||||
name 'oxmysql'
|
||||
description 'Database wrapper for FiveM utilising node-mysql2 offering improved performance and security.'
|
||||
version '1.8.3'
|
||||
version '1.8.4'
|
||||
url 'https://github.com/overextended/oxmysql'
|
||||
author 'overextended'
|
||||
use_fxv2_oal 'yes'
|
||||
lua54 'yes'
|
||||
|
||||
server_scripts {
|
||||
-- '/server:4837', Disabled until the heat death of the universe (or recommended artifact updates)
|
||||
'oxmysql.js',
|
||||
'wrapper.lua'
|
||||
}
|
||||
|
||||
+3
-2
@@ -28,8 +28,9 @@ CreateThread(function()
|
||||
end, 'GET')
|
||||
end)
|
||||
|
||||
-- Check for a recent native since the recommended artifact doesn't support JS async_retval or dependency constraints
|
||||
if not GetEntityAttachedTo then
|
||||
-- Check for the existance of a native from FXServer 4837 to disable Lua exports
|
||||
-- Shame dependency constraints were added immediately after the recommended build
|
||||
if not MumbleSetPlayerMuted then
|
||||
|
||||
---@param query string
|
||||
---@param parameters? table
|
||||
|
||||
+41
-35
@@ -52,45 +52,51 @@ global.exports('prepare', (query, parameters, cb, resource = GetInvokingResource
|
||||
preparedStatement(query, parameters, resource).then((result) => safeCallback(cb || parameters, result));
|
||||
});
|
||||
|
||||
// Check for a recent native (~server artifact 4700) to enable JS exports
|
||||
if (GetEntityAttachedTo !== undefined || !GetResourceMetadata(GetCurrentResourceName(), 'server_script', 1)) {
|
||||
global.exports('prepareSync', async (query, parameters) => {
|
||||
const result = await preparedStatement(query, parameters, GetInvokingResource());
|
||||
return result;
|
||||
});
|
||||
try {
|
||||
// Check for the existance of a native from FXServer 4837 to enable JS exports
|
||||
if (MumbleSetPlayerMuted || !GetResourceMetadata(GetCurrentResourceName(), 'server_script', 1)) {
|
||||
global.exports('prepareSync', async (query, parameters) => {
|
||||
const result = await preparedStatement(query, parameters, GetInvokingResource());
|
||||
return result;
|
||||
});
|
||||
|
||||
global.exports('executeSync', async (query, parameters) => {
|
||||
const result = await execute(query, parameters, GetInvokingResource());
|
||||
return result;
|
||||
});
|
||||
global.exports('executeSync', async (query, parameters) => {
|
||||
const result = await execute(query, parameters, GetInvokingResource());
|
||||
return result;
|
||||
});
|
||||
|
||||
global.exports('insertSync', async (query, parameters) => {
|
||||
const result = await execute(query, parameters, GetInvokingResource());
|
||||
return result && result.insertId;
|
||||
});
|
||||
global.exports('insertSync', async (query, parameters) => {
|
||||
const result = await execute(query, parameters, GetInvokingResource());
|
||||
return result && result.insertId;
|
||||
});
|
||||
|
||||
global.exports('updateSync', async (query, parameters) => {
|
||||
const result = await execute(query, parameters, GetInvokingResource());
|
||||
return result && result.affectedRows;
|
||||
});
|
||||
global.exports('updateSync', async (query, parameters) => {
|
||||
const result = await execute(query, parameters, GetInvokingResource());
|
||||
return result && result.affectedRows;
|
||||
});
|
||||
|
||||
global.exports('fetchSync', async (query, parameters) => {
|
||||
const result = await execute(query, parameters, GetInvokingResource());
|
||||
return result;
|
||||
});
|
||||
global.exports('fetchSync', async (query, parameters) => {
|
||||
const result = await execute(query, parameters, GetInvokingResource());
|
||||
return result;
|
||||
});
|
||||
|
||||
global.exports('singleSync', async (query, parameters) => {
|
||||
const result = await execute(query, parameters, GetInvokingResource());
|
||||
return result && result[0];
|
||||
});
|
||||
global.exports('singleSync', async (query, parameters) => {
|
||||
const result = await execute(query, parameters, GetInvokingResource());
|
||||
return result && result[0];
|
||||
});
|
||||
|
||||
global.exports('scalarSync', async (query, parameters) => {
|
||||
const result = await execute(query, parameters, GetInvokingResource());
|
||||
return result && result[0] && Object.values(result[0])[0];
|
||||
});
|
||||
global.exports('scalarSync', async (query, parameters) => {
|
||||
const result = await execute(query, parameters, GetInvokingResource());
|
||||
return result && result[0] && Object.values(result[0])[0];
|
||||
});
|
||||
|
||||
global.exports('transactionSync', async (queries, parameters) => {
|
||||
const result = await transaction(queries, parameters, GetInvokingResource());
|
||||
return result;
|
||||
});
|
||||
}
|
||||
global.exports('transactionSync', async (queries, parameters) => {
|
||||
const result = await transaction(queries, parameters, GetInvokingResource());
|
||||
return result;
|
||||
});
|
||||
}
|
||||
} catch(e) {
|
||||
setTimeout(() => {
|
||||
console.log(`^3Unable to load enhanced sync exports (download FXServer 4837+)^0`);
|
||||
}, 1000)
|
||||
}
|
||||
Reference in new issue
Block a user