lib/db.js
function modelMethod(model, method, data, done) {
  model[method](data).then(function(results) {
    done(null, results);
  })
  .catch(function(error) {
    // Try again on timeout
    if (error.message == "connect ETIMEDOUT") {
      modelMethod(model, method, data, done);
      return;
    }
    done(error);
  });
}
function modelMethod(model, method, data, done) {
  model[method](data).then(function(results) {
    done(null, results);
  })
  .catch(function(error) {
    // Try again on timeout
    if (error.message == "connect ETIMEDOUT") {
      modelMethod(model, method, data, done);
      return;
    }
    done(error);
  });
}
function modelMethod ( model , method , data , done ) { model [ method ] ( data ) . then ( function ( results ) { done ( null , results ) ; } ) . catch ( function ( error ) { // Try again on timeout if ( error . message == "connect ETIMEDOUT" ) { modelMethod ( model , method , data , done ) ; return ; } done ( error ) ; } ) ; }
Queue-ify db request
Queue - ify db request