Code Monkey home page Code Monkey logo

mysql-async-wrapper's People

Contributors

abhay2012 avatar orahul1 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

orahul1

mysql-async-wrapper's Issues

Try catch error

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 proyect is deployed with typescript version 3.5.3

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.