abhay2012 / mysql-async-wrapper Goto Github PK
View Code? Open in Web Editor NEWThis is a Wrapper class, which helps to get rid of callbacks of mysql package functions and provides a way to use them in async await (es7) syntax
This is a Wrapper class, which helps to get rid of callbacks of mysql package functions and provides a way to use them in async await (es7) syntax
I am currently using your package, but when for example there is a "syntax error" in a query the catch does not capture the error but in the node console it shows the following error, the whole package works fine less when there is an error in the different queries
(node:11239) UnhandledPromiseRejectionWarning: TypeError: ER_PARSE_ERROR is not a function
at Array.findIndex ()
at BaseDatabase. (/opt/node/navis/server/node_modules/mysql-async-wrapper/dist/index.js:163:56)
at Generator.next ()
at /opt/node/navis/server/node_modules/mysql-async-wrapper/dist/index.js:24:71
at new Promise ()
at __awaiter (/opt/node/navis/server/node_modules/mysql-async-wrapper/dist/index.js:20:12)
at Query.queryString._connection.query (/opt/node/navis/server/node_modules/mysql-async-wrapper/dist/index.js:160:93)
at Query. (/opt/node/navis/server/node_modules/mysql/lib/Connection.js:525:10)
at Query._callback (/opt/node/navis/server/node_modules/mysql/lib/Connection.js:491:16)
at Query.Sequence.end (/opt/node/navis/server/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
(node:11239) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11239) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
My node version is 10.19.0
My db configuration file is:
import mysql from "mysql";
const BaseDatabase = require("mysql-async-wrapper").default;
const pool = mysql.createPool({
host: '127.0.0.1',
user: 'root',
password: '',
database: 'my_db'
})
const db = new BaseDatabase(pool);
export default db;
my file controller is:
import { Request, Response} from 'express';
import Database from '../../db';
class ClientesController{
public async obtenerClientes(req: Request, res: Response){
let data=req['body'];
let db = await Database.getConnection();
try{
let result_count = await db.executeQuery(`call pa_clientes_contar("${data['filtro']}")`);
let result_data = await db.executeQuery(`call pa_clientes_obtener_clientes(${data['numeroFila']},${data['tamanioPagina']},${data['filtro']})`);
return res.status(200).json({data:result_count, data2: result_data});
}catch(e){
return res.status(500).json({message: 'Error al obtener los clientes',err:e});
}finally{
await db.close();
}
}
Really I have no idea what I do wrong or what is the problem.
Regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.