Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Property 'releaseConnection' does not exist on type 'Pool'. #1761

Closed
amirhossein-karimi opened this issue Dec 27, 2022 · 5 comments
Closed

Comments

@amirhossein-karimi
Copy link

amirhossein-karimi commented Dec 27, 2022

Hi,

I use the connection pool and according to the documentation, when I release it (connection), I face the following problem .
Property 'releaseConnection' does not exist on type 'Pool'.

notes : i used typescript

and this is my code
pool.getConnection(function (err, conn) { // Do something with the connection conn.query("CREATE DATABASE IF NOT EXISTS zxc CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;", (err, rows, fields) => { if (err) throw err; }); pool.releaseConnection(conn); })

@jake-knerr
Copy link

I am having the same problem. I am using conn.release() instead.

@JiaJiaJiang
Copy link

JiaJiaJiang commented May 14, 2023

The doc here is wrong, please fix it.
The correct one is conn.release, not pool.releaseConnection

@wellwelwel
Copy link
Collaborator

@JiaJiaJiang, the documentation is correct.

The releaseConnection is used as a method from the pool, like:

pool.getConnection((err, conn) => {
  pool.releaseConnection(conn);
});

The release is used as a method of the connection from pool, like:

pool.getConnection((err, conn) => {
  conn.release();
});

In fact, the type releaseConnection is missing in Pool.

@wellwelwel
Copy link
Collaborator

@amirhossein-karimi and @jake-knerr, can you check this in ^3.3.4 version?

@wellwelwel
Copy link
Collaborator

After version ^3.3.4, you can follow this example for releaseConnection:

const pool = mysql.createPool(access);
pool.getConnection((_err, conn) => {
pool.releaseConnection(conn);
});

And for release:

const pool = mysql.createPool(access);
pool.getConnection((_err, conn) => {
conn.release();


I'm closing this Issue, but feel free to ask anything 🙋🏻‍♂️

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants