When using a pool connection you seem to be missing the beginTransaction method.
const connection = mysql.createPool({
host: process.env.HOST,
user: process.env.USER,
password: process.env.PASSWORD,
database: process.env.DATABASE,
connectionLimit: 10
})
here is the current pool connection I am using, could be a user error but I did not see the option available to the pool.
Hi @hkd987 this is as designed. The createPool method doesn't return a connection, it returns a pool object. A transaction is specific to a single connection, so you need to first get the specific connection you want to begin a transaction on from the pool using .getConnection. Then you can begin and end the transaction and return to the pool when done 馃憤
Most helpful comment
Hi @hkd987 this is as designed. The
createPoolmethod doesn't return a connection, it returns a pool object. A transaction is specific to a single connection, so you need to first get the specific connection you want to begin a transaction on from the pool using.getConnection. Then you can begin and end the transaction and return to the pool when done 馃憤