当我在node.js中关闭数据库连接时,出现此错误
Cannot enqueue Query after invoking quit
.
这是我的代码
socket.on('adminConnect', function (email) {
connection = mysql.createConnection(db_config); // db_config has all details of database
connection.connect(); // no problem in connection
connection.query("SELECT id FROM user WHERE email = '" + email + "' ", function (err, results, fields) {
if (err) throw err;
if (results[0]) {
// Some code
connection.end(); // its giving error "Cannot enqueue Query after invoking quit."
} else {
console.log("no id");
}
});
});