node-mysql2
node-mysql2 copied to clipboard
conn.release() does not return a promise when using mysql2/promise library
var mysql = require('mysql/promise');
var bluebird = require('bluebird);
const pool = mysql.createPool({
connectionLimit: CONFIG.mysql.connectionLimit,
host : CONFIG.mysql.host,
user : CONFIG.mysql.user,
password : CONFIG.mysql.password,
database : CONFIG.mysql.database,
Promise : bluebird
});
const newActivityCount = co.wrap(function *(memberId) {
var sql = "SELECT 1";
var conn = yield pool.getConnection();
var results = yield conn.execute(sql);
yield conn.release(); <-- ERRORS OUT
return results[0][0].newActivity;
});
ERROR THROWN IS AS FOLLOWS:
You may only yield a function, promise, generator, array, or object, but the following object was passed: "undefined"
For details see here
The .release() method doesn't take a callback, either. It's not an async method.