Closed gajus closed 9 years ago
I'll have a look at this
So having had a look and a think, the only way I feel this could work would be if the promise returned the connection, so you'd handle it like so:
var mysql = require('promise-mysql');
var connection;
mysql.createConnection({
host: 'localhost',
user: 'sauron',
password: 'theonetruering',
database: 'mordor'
}).catch(function(error){
//logs out the error
console.log(error);
}).then(function(conn){
connection = conn;
});
Is this what you're looking for @gajus?
Added in 84c7ed9fcc60a81cbc7fd3bdd6e1e4a87a1fcbe9
createConnection
does not return a promise. While it is not necessary to know when connection to database is successful (because.query
is aware of thecreateConnection
state), it would be useful in order to catch unsuccessful connection error.