CodeFoodPixels / node-promise-mysql

A wrapper for mysqljs/mysql that wraps function calls with Bluebird promises.
MIT License
338 stars 63 forks source link

Destructuring pool object #100

Closed James2516 closed 5 years ago

James2516 commented 5 years ago

Instead of calling connection.query(...), I want to simplify the syntax to:

const query = connection.query;
query(...);
query(...);

But it's giving an error:

Gotten error TypeError: Cannot read property 'apply' of undefined at node_modules/promise-mysql/lib/helper.js:16:24 at Promise._execute (node_modules/bluebird/js/release/debuggability.js:303:9) at Promise._resolveFromExecutor (node_modules/bluebird/js/release/promise.js:483:18) at new Promise (node_modules/bluebird/js/release/promise.js:79:10) at promiseCallback (node_modules/promise-mysql/lib/helper.js:6:10) at pool.query (node_modules/promise-mysql/lib/pool.js:22:28)

Is there any way to fix this?

move-zig commented 5 years ago

Maybe you want something like

const query = connection.query.bind(connection);