jano-mysql
[EN]
It is a library that uses the mysql
driver to keep code clean, simple, organized and with Promises.
Requirements
Installation
npm install jano-mysql --save
or
yarn add jano-mysql
Examples of use
- To load the library, put the database settings inside the constructor.
const mysql = host: 'localhost' user: 'root' database: 'meubanco' password: '' port: 3306;
- Transaction
Starts an opentransaction
let conexao = await mysql;
- Execute commands in the transaction
let transacaoA = await mysql let transacaoB = await mysql
- Terminates a connection (non-mandatory parameter)
true = commit false = rollback
let conexaoEncerrada = await conexao;
- Free Query, enter whatever you want, the return will be in
.content
let motivos = await mysql;console;
- Insert/Update record
let insert = await mysql;console;
- Return records from a procedure
let procedure = await mysql;console;
[PT-BR]
É uma biblioteca que utiliza o driver do mysql
mantendo um código mais limpo, simples, organizado com Promises.
Requisitos
Instalação
npm install jano-mysql --save
ou
yarn add jano-mysql
Exemplos de uso
- Para carregar a biblioteca
coloque no construtor as configurações do banco de dados.
const mysql = host: 'localhost' user: 'root' database: 'meubanco' password: '' port: 3306;
- Transação
Inicia uma conexão aberta comtransaction
let conexao = await mysql;
- Execute comandos na transação
let transacaoA = await mysql let transacaoB = await mysql
- Encerra uma conexão (paramêtro não obrigatório)
true = commit false = rollback
let conexaoEncerrada = await conexao;
- Query livre, digite o que quiser, o retorno ficará em
.content
let motivos = await mysql;console;
- Inserir/Atualizar registro
let insert = await mysql;console;
- Retornar registros de uma procedure
let procedure = await mysql;console;