2.0.6 • Published 4 years ago
@rededompedro/mysql v2.0.6
MySQL
A MySQL Wrapper for https://github.com/mysqljs/mysql that wraps function calls with promises. Currently we only support pool connections.
Installation
npm i @dev2world/mysql
yarn add @dev2world/mysql
Usage
const mysql = require('@dev2world/mysql');
const config = {
password: 'secret',
user: 'root',
host: 'localhost',
port: 3306,
database: 'db_test',
connectionLimit: 3
};
const pool = mysql.createPool(config);
(async () => {
let results = await pool.query('SELECT * FROM db.table')
})()
Transactions
const conn = await pool.getConnection()
await conn.beginTransaction()
let result = await conn.query('INSERT INTO db_test.new_table(name, address) VALUES("Testando", "Testando")')
await conn.commit()