lib/db.js
function runSQL (sql, config, conn, replacements) {
  return new Promise(function (resolve, reject) {
    if (!config && !conn) {
      reject('Must set config or connection')
    }

    if (!sql) {
      reject('Need some sql')
    }

    if (!conn) {
      conn = getConnection(config)
    }

    replacements = replacements || {}

    conn.query(sql, { replacements: replacements }).then(function (ret) {
      return resolve({'ret': ret, 'conn': conn})
    }).catch(function (err) {
      return reject(err)
    })
  })
}
function runSQL (sql, config, conn, replacements) {
  return new Promise(function (resolve, reject) {
    if (!config && !conn) {
      reject('Must set config or connection')
    }

    if (!sql) {
      reject('Need some sql')
    }

    if (!conn) {
      conn = getConnection(config)
    }

    replacements = replacements || {}

    conn.query(sql, { replacements: replacements }).then(function (ret) {
      return resolve({'ret': ret, 'conn': conn})
    }).catch(function (err) {
      return reject(err)
    })
  })
}
function runSQL ( sql , config , conn , replacements ) { return new Promise ( function ( resolve , reject ) { if ( ! config && ! conn ) { reject ( 'Must set config or connection' ) } if ( ! sql ) { reject ( 'Need some sql' ) } if ( ! conn ) { conn = getConnection ( config ) } replacements = replacements || { } conn . query ( sql , { replacements : replacements } ) . then ( function ( ret ) { return resolve ( { 'ret' : ret , 'conn' : conn } ) } ) . catch ( function ( err ) { return reject ( err ) } ) } ) }
Run SQL as promise
@param  {string} sql          The SQL to run
@param  {Object} config          The config object.
@param  {string} config.dialect  The db dialect sqlite | mysql.
@param  {string} config.host     The db host.
@param  {string} config.database The db database name.
@param  {string} config.username The db username.
@param  {string} config.password The db password.
@param  {Object} conn            Sequelize connection.
@param  {Object} replacements    Possiblle replacements.
@return {Object}                 Promise
Run SQL as promise