Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

fivem-mysql-async-js

CrazyBitDev38MIT0.1.2

Requires fivem-mysql-async resource.
Compatible with Javascript and Typescript.

fivem, mysql-async, fivem-mysql-async

readme

fivem-mysql-async-js

Requires fivem-mysql-async resource.
Compatible with Javascript and Typescript.

npm version npm downloads license gzip size


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, otherwise false


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) => {
    ...
})