niczak
1/22/2014 - 7:35 PM

promiseTest.js

function getRow(id) {
  var dfd = Q.defer();
  var query = db.query('SELECT * FROM table WHERE lookUp = ?', id, function(err, result) {
    if(err) { dfd.reject(err); }
    else { dfd.resolve(result); }
  });
  return dfd.promise;
}