Find us on facebook

Oct 29, 2016

Connection pool and query within Lambda nodejs runtime

var pool = openConnectionToDB(host,username,password,database);

pool.getConnection(function(err,connection){
console.log('connected as id ' + connection.threadId);
        //Query
connection.query("SELECT * FROM ?? WHERE ?? = ? AND deleted_at IS NULL",['table_name','id',subject],function(err,rows){
           if(!err) {
             if(typeof rows[0] == 'undefined'){
               connection.release();
               connection.destroy();
             }
           }
 });
});

No comments:

Post a Comment