For example, in a socket.io connection event handleServer is the callback function:
function handleServer(s)
{
m = new mysql();
m.Query("blabla",function(r)
{
console.log(r)
});
m.Close();
}
mysql object is:
m = require("mysql");
function Mysql()
{
this.mysql = m.createConnection({ blablah });
this.mysql.connect(function(err)
{
// blabla
});
}
Mysql.prototype.Query = function(q, callback)
{
this.mysql.query(q, function(err, v)
{
callback(v);
})
}
In the first function call (handleServer) the query is correctly executed, but in the successive calls this fails throwing
"m has no method 'createConnection' "
Theoretically should not create another connection?