CodeFoodPixels / node-promise-mysql

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

Added release() function to connection to enable better-behaved pooled connections. #22

Closed DanHulton closed 7 years ago

DanHulton commented 8 years ago
    DB_POOL.getConnection().then(function(connection) {
        connection.query('SELECT * FROM characters WHERE uid = ?', [id]).then(function(rows) {
            // Release the connection back into the pool
            connection.release();

            ...

        });
    });
CodeFoodPixels commented 8 years ago

I'm sorry I've not done anything with this yet. I am aware of the pull request, I just need to run some tests before I can merge

On Sun, 21 Aug 2016 at 03:04 Dan Hulton notifications@github.com wrote:

DB_POOL.getConnection().then(function(connection) {
    connection.query('SELECT * FROM characters WHERE uid = ?', [id]).then(function(rows) {
        // Release the connection back into the pool
        connection.release();

        ...

    });
});

You can view, comment on, or merge this pull request online at:

https://github.com/lukeb-uk/node-promise-mysql/pull/22 Commit Summary

  • Added release() function to connection to enable better-behaved pooled connections.

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lukeb-uk/node-promise-mysql/pull/22, or mute the thread https://github.com/notifications/unsubscribe-auth/AEjy1NlyQRGTIOE5kmiwnJ2mltHsS-Ldks5qh7I6gaJpZM4JpNN0 .

CodeFoodPixels commented 7 years ago

Thanks!

zawadzkip commented 7 years ago

First off, thanks for your support in creating and maintaining this library. Question regarding the connection pools,

const pool = await mysql.createPool(...);
const connection = await pool.getConnection();
await connection.query(...);
await connection.release();

This would be the workflow, in an async-await environment for taking a connection from a pool, querying against it, and then returning the connection back to the pool so it may be consumed by other services?

CodeFoodPixels commented 7 years ago

I believe that is correct, yes.

On Thu, 24 Aug 2017, 19:14 Patrick Zawadzki notifications@github.com wrote:

First off, thanks for your support in creating and maintaining this library. Question regarding the connection pools,

const pool = await mysql.createPool(...); const connection = await pool.getConnection(); await connection.query(...); await connection.release();

This would be the workflow, in an async-await environment for taking a connection from a pool, querying against it, and then returning the connection back to the pool so it may be consumed by other services?

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/lukeb-uk/node-promise-mysql/pull/22#issuecomment-324714578, or mute the thread https://github.com/notifications/unsubscribe-auth/AEjy1GhYo5lxdCYGP_TDEKfcKar2uv2Oks5sbb2QgaJpZM4JpNN0 .