CodeFoodPixels / node-promise-mysql

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

Any plan to support createPoolCluster? #33

Closed Arnoldnuo closed 3 years ago

Arnoldnuo commented 7 years ago

I love async/await, but this lib don`t support createPoolCluser, how can i change createPoolCluser to promise?

CodeFoodPixels commented 7 years ago

I have no immediate plan to add it myself. Maybe eventually if I get time. If you want to look at implementing it, see how lib/pool.js and lib/connection.js work and feel free to submit a pull request.

move-zig commented 3 years ago

I'm working on this, but I need to be able to create a promise-mysql Pool from an existing underlying mysql Pool. Something like

  class pool {
-     constructor(config = {}) {
+     constructor(config = {}, _pool) {
+         if (_pool) {
+             this.pool = _pool;
+             return this;
+         }
  }

How do you feel about that, @CodeFoodPixels ?

The alternative is to have PoolCluster.of() return an underlying (non-promisified) pool.

CodeFoodPixels commented 3 years ago

Completely happy with that, it's similar to what happens in the connection

move-zig commented 3 years ago

I've made the changes in the cluster branch.

I'm not familiar with tap and sinon though. I'm having trouble with one test. poolCluster.on can be called with one or two parameters and I can't seem to get the test with one parameter working.

Can you take a look?

CodeFoodPixels commented 3 years ago

This has been added in #146 and published to NPM in version 5.0.0, thanks @move-zig!