fivem-mysql-async-js
v0.1.2
Published
Requires [fivem-mysql-async](https://github.com/brouznouf/fivem-mysql-async) resource. Compatible with Javascript and Typescript.
Downloads
20
Maintainers
Readme
fivem-mysql-async-js
Requires fivem-mysql-async resource.
Compatible with Javascript and Typescript.
Installation
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'
Functions
execute
Execute a query with no result required.
query
(type: string) query.params
(type: Object) paramaters (optional).Returns: Promise, Number of rows updated
fetchAll
Execute a query and fetch all results.
query
(type: string) query.params
(type: Object) paramaters (optional).Returns: Promise, Query results
fetchScalar
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
insert
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
store
Stores a query for later execution.
query
(type: string) query.Returns: Promise
transaction
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
Examples
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) => {
...
})