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 @@ Inserts a new entry into the database and returns the insert id for the row, if
```
**Sync**
```lua
local id = exports.oxmysql:insertSync('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', {playerIdentifier, firstName, lastName})
if id then
print(id)
end
CreateThread(function()
local id = exports.oxmysql:insertSync('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', {playerIdentifier, firstName, lastName})
if id then
print(id)
end
end)
```
=== "JavaScript"
**Async**
@@ -30,7 +32,9 @@ Inserts a new entry into the database and returns the insert id for the row, if
```
**Sync**
```js
const id = exports.oxmysql.insertSync('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', [playerIdentifier, firstName, lastName]) {
if (id)
console.log(id)
setImmediate(async () => {
const id = exports.oxmysql.insertSync('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', [playerIdentifier, firstName, lastName]) {
if (id)
console.log(id)
})
```