Wrap Sync exports in CreateThread/setImmediate

This commit is contained in:
Linden committed 2021-10-25 08:09:00 +11:00
1 parent 9af6205bb7
commit 2c2f4e0661
5 files changed
+59 -39

No files matched your search

+11 -7
View File
@@ -15,10 +15,12 @@ Updates an entry in the database and returns the number of affected rows.
```
**Sync**
```lua
local id = exports.oxmysql:insertSync('UPDATE users SET firstname = ? WHERE identifier = ? ', {newName, playerIdentifier})
if affectedRows then
print(affectedRows)
end
CreateThread(function()
local id = exports.oxmysql:insertSync('UPDATE users SET firstname = ? WHERE identifier = ? ', {newName, playerIdentifier})
if affectedRows then
print(affectedRows)
end
end)
```
=== "JavaScript"
**Async**
@@ -30,7 +32,9 @@ Updates an entry in the database and returns the number of affected rows.
```
**Sync**
```js
const id = exports.oxmysql.insertSync('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier]) {
if (affectedRows)
console.log(affectedRows)
setImmediate(async () => {
const id = exports.oxmysql.insertSync('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier]) {
if (affectedRows)
console.log(affectedRows)
})
```