Node mysql TypeError: connection.beginTransaction is not a function

Viewed 46

I have created a connection pool and exported why this error is still reported

TypeError: connection.beginTransaction is not a function

connections.getConnection((err, conn) => {
  conn.connect((err) => {
    if (err) {
      console.log("fail:", err);
    } else {
      console.log("success~");
    }
  })
});
module.exports = connections.promise();


const connection = require("../app/database");
try {
      await connection.beginTransaction()
    } catch (err) {
      console.log(err,'err')
}
0 Answers
Related