how does mysql.createPool work? #1747
MassMessage
started this conversation in
General
Replies: 1 comment 3 replies
-
you are creating a new pool instance in What you should do instead ( I'm using async api but callback version is similar ) const pool = mysql.createPool(connectOptions);
const foo = async () => {
const conn = await pool.getConnection();
const [rows] = conn.query('select * from YYY');
conn.release();
console.log(rows);
};
const baa = async () => {
// or just do .query() on a pool, it'll do .getConnection + query + release internally
const [rows] = pool.query('select * from YYY');
console.log(rows);
}; |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
how does
mysql.createPool
work? let's say i have the following code:i do call
foo
and later onbaa
. in the callfoo
the connection is created and inbaa
and subsequents call togetConn
i'll get just the same connection instance created byfoo
, is that right?Beta Was this translation helpful? Give feedback.
All reactions