Skip to content
This repository was archived by the owner on Apr 29, 2025. It is now read-only.

Commit 6adaa0b

Browse files
committed
feat(lib/lua): add options and 'return_callback_errors'
Resolves #237. See issue for more information.
1 parent bfe660b commit 6adaa0b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lib/MySQL.lua

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
local promise = promise
22
local Await = Citizen.Await
3-
local GetCurrentResourceName = GetCurrentResourceName()
3+
local resourceName = GetCurrentResourceName()
44
local GetResourceState = GetResourceState
55

6+
local options = {
7+
return_callback_errors = false
8+
}
9+
10+
for i = 1, GetNumResourceMetadata(resourceName, 'mysql_option') do
11+
local option = GetResourceMetadata(resourceName, 'mysql_option', i - 1)
12+
options[option] = true
13+
end
14+
615
local function await(fn, query, parameters)
716
local p = promise.new()
17+
818
fn(nil, query, parameters, function(result, error)
919
if error then
1020
return p:reject(error)
1121
end
1222

1323
p:resolve(result)
14-
end, GetCurrentResourceName, true)
24+
end, resourceName, true)
25+
1526
return Await(p)
1627
end
1728

@@ -60,7 +71,7 @@ local oxmysql = exports.oxmysql
6071
local mysql_method_mt = {
6172
__call = function(self, query, parameters, cb)
6273
query, parameters, cb = safeArgs(query, parameters, cb, self.method == 'transaction')
63-
return oxmysql[self.method](nil, query, parameters, cb, GetCurrentResourceName, false)
74+
return oxmysql[self.method](nil, query, parameters, cb, resourceName, options.return_callback_errors)
6475
end
6576
}
6677

0 commit comments

Comments
 (0)