Requires fivem-mysql-async resource.
Compatible with Javascript and Typescript.
Using npm:
npm install fivem-mysql-async-js
Using yarn:
yarn add fivem-mysql-async-js
Import modules:
import * as MySQL from 'fivem-mysql-async-js'
or
import { execute, fetchAll, fetchScalar, insert, store, transaction } from 'fivem-mysql-async-js'
-
Execute a query with no result required.
query
(type: string) query.
params
(type: Object) paramaters (optional).Returns: Promise, Number of rows updated
-
Execute a query and fetch all results.
query
(type: string) query.
params
(type: Object) paramaters (optional).Returns: Promise, Query results
-
Execute a query and fetch the first column of the first row.
Useful for count function by example.query
(type: string) query.
params
(type: Object) paramaters (optional).Returns: Promise, Value of the first column in the first row
-
Execute a query and retrieve the last id insert.
query
(type: string) query.
params
(type: Object) paramaters (optional).Returns: Promise, Value of the last insert id
-
Stores a query for later execution.
query
(type: string) query.Returns: Promise
-
Execute a List of querys and returns bool true when all are executed successfully.
query
(type: string) query.
params
(type: Object) paramaters (optional).Returns: Promise,
true
if the transaction was successful, otherwisefalse
var position = await MySQL.fetchScalar('SELECT position FROM users WHERE identifier = @identifier', {
'@identifier': identifier
})
or
MySQL.fetchScalar('SELECT position FROM users WHERE identifier = @identifier', {
'@identifier': identifier
}).then((position) => {
...
})