Wednesday 17 May 2017

unable to end the mysql connection using the promise

Followings are my piece of code, please have a look into it.

var mysql = require('promise-mysql');
var connection;

mysql.createConnection({host:'Ip', user:'qa', password: '******'}).then(function(conn){
connection = conn;
return connection.query(firstInput);
})
.then(function(rows){
console.log(rows);
})

.then(function(){
console.log("End of DB Con.");
return connection.end();

})
.catch(function(error){
//logs out the error
console.log(error);
});

Once I try to execute the code for different Jasmine tests all works Ok as it's fetch the records from DB but when it comes to executing the last jasmine test it retain the records from second last query that was executed in second last test. This is the exact problem!



via Abid Rana

No comments:

Post a Comment