mysql-functions
A simple wrapper for mysql (A pure node.js JavaScript Client implementing the MySql protocol). All functions returns Promise. Use Node.js v.8 or higher with support for async/await.
Installation
From npm.
npm install mysql-functions
Or from git.
npm install roboulbricht/mysql-functions
class TConnection
It is created in function TDatabase.connectPool. It has the same functions as TDatabase. You can have many opened TConnection.
class TDatabase
Function: connect()
Establishing the connection to the database.
var Database = ; var connection_string = host: "localhost" user: "root" password: "password" database: "mydb" var db = connection_string;db ;
Function: connectPool()
Establishing the connection to the database.
var Database = ; var connection_string = connectionLimit : 10 host: "localhost" user: "root" password: "password" database: "mydb" var db = connection_string;db ;
Function: execute(sql, params)
Execute the query without returning the result table. Good for insert queries.
sql
{String} The SQL statement to be executed.params
{Array[]} An array of arrays containing the parameter definitions.
var Database = ; var connection_string = host: "localhost" user: "root" password: "password" database: "mydb" var db = connection_string;db ;
Property: identity
Return the last identity fro previous execute.
var result1 = await db;console;
Function: query(sql, params)
Execute the query which returns the result table.
sql
{String} The SQL statement to be executed.params
{Array[]} An array of arrays containing the parameter definitions.
var q = await db;console;
Property: fields
Return the fields from last query.
Function: beginTransaction()
Begin the transaction.
var Database = ; var connection_string = host: "localhost" user: "root" password: "password" database: "mydb" var db = connection_string;db ;
Function: commitTransaction()
Commit the transaction.
Function: rollbackTransaction()
Rollback the transaction.