Hi I have connection with db2 following way which works fine
require("ifxnjs").open(connectionString, function(err, con){
If(err){
console.log(err);
} else {
con.query(........){
}
}
});
I am trying to create a separate connection factory that can be called in any query. The code I have is
function confactory(){
db=require("ifxnjs).open(connectionString, function(err, conn){
if(err){} else {
console.log('connected');
}
})
return db
}
module.exports=confactory();
Than I access the connection in project
var db=require('./cofactory.js');
db.query('select * from emp', function(err, result){
if(err){}
else { cons
}
})
When I run the program I get error for TypeError Can not read property 'query' of undefined Please let me know how I can fix this issue. Thanks