index.js
function exec(query, config, done) {
  if(!query || (typeof query != 'string')){
    throw new Error('Node-SQL: query was not in the correct format.');
    return;
  }
  if(!config || (typeof config != 'object')){
    throw new Error('Node-SQL: config was not in the correct format.');
    return;
  }
  if(!done || (typeof done != 'function')){
    done = function(a, b){};
  }
  var connection = new Connection(config);
  connection.on('connect', function(err) {
    if(err){
      done(err, null);
      return;
    }
    var request = new Request(query, function(_err) {
      if (_err) {
        done(_err, null);
        return;
      }
      connection.close();
    });
    var result = [];
    request.on('row', function(columns) {
      var row = {};
      columns.forEach(function(column) {
        row[column.metadata.colName] = column.value;
      });
      result.push(row);
    });
    request.on('doneProc', function(rowCount, more, returnStatus) {
      if(returnStatus == 0) done(null, result);
    });
    connection.execSql(request);
  });
}
function exec(query, config, done) {
  if(!query || (typeof query != 'string')){
    throw new Error('Node-SQL: query was not in the correct format.');
    return;
  }
  if(!config || (typeof config != 'object')){
    throw new Error('Node-SQL: config was not in the correct format.');
    return;
  }
  if(!done || (typeof done != 'function')){
    done = function(a, b){};
  }
  var connection = new Connection(config);
  connection.on('connect', function(err) {
    if(err){
      done(err, null);
      return;
    }
    var request = new Request(query, function(_err) {
      if (_err) {
        done(_err, null);
        return;
      }
      connection.close();
    });
    var result = [];
    request.on('row', function(columns) {
      var row = {};
      columns.forEach(function(column) {
        row[column.metadata.colName] = column.value;
      });
      result.push(row);
    });
    request.on('doneProc', function(rowCount, more, returnStatus) {
      if(returnStatus == 0) done(null, result);
    });
    connection.execSql(request);
  });
}
function exec ( query , config , done ) { if ( ! query || ( typeof query != 'string' ) ) { throw new Error ( 'Node-SQL: query was not in the correct format.' ) ; return ; } if ( ! config || ( typeof config != 'object' ) ) { throw new Error ( 'Node-SQL: config was not in the correct format.' ) ; return ; } if ( ! done || ( typeof done != 'function' ) ) { done = function ( a , b ) { } ; } var connection = new Connection ( config ) ; connection . on ( 'connect' , function ( err ) { if ( err ) { done ( err , null ) ; return ; } var request = new Request ( query , function ( _err ) { if ( _err ) { done ( _err , null ) ; return ; } connection . close ( ) ; } ) ; var result = [ ] ; request . on ( 'row' , function ( columns ) { var row = { } ; columns . forEach ( function ( column ) { row [ column . metadata . colName ] = column . value ; } ) ; result . push ( row ) ; } ) ; request . on ( 'doneProc' , function ( rowCount , more , returnStatus ) { if ( returnStatus == 0 ) done ( null , result ) ; } ) ; connection . execSql ( request ) ; } ) ; }
Executes a sql query
@param {string} query  -- good old query string
@param {Object} config -- standard tedious config object
@param {Function} done -- standard node callback
Executes a sql query