lib/impl/updateRules.js
function updateRules(rulesToUpdate, cb) {
    function updateRule(ruleDetails, cb1) {
      var id = ruleDetails._id;

      rulesModel.findOne({_id: id}, function(err, ruleToUpdate) {
        if (err) {
          return cb1(err);
        }

        if (ruleToUpdate === null && !options.createIfNotFound) {
          return cb1(new Error("No " + ruleType + " rule matches id " + id));
        } else if (ruleToUpdate === null && options.createIfNotFound) {
          ruleToUpdate = new rulesModel(ruleDetails);
        }

        for (var saveKey in ruleDetails) { // eslint-disable-line guard-for-in
          ruleToUpdate[saveKey] = ruleDetails[saveKey];
        }

        ruleToUpdate.save(cb1);
      });
    }

    async.map(rulesToUpdate, updateRule, cb);
  }
function updateRules(rulesToUpdate, cb) {
    function updateRule(ruleDetails, cb1) {
      var id = ruleDetails._id;

      rulesModel.findOne({_id: id}, function(err, ruleToUpdate) {
        if (err) {
          return cb1(err);
        }

        if (ruleToUpdate === null && !options.createIfNotFound) {
          return cb1(new Error("No " + ruleType + " rule matches id " + id));
        } else if (ruleToUpdate === null && options.createIfNotFound) {
          ruleToUpdate = new rulesModel(ruleDetails);
        }

        for (var saveKey in ruleDetails) { // eslint-disable-line guard-for-in
          ruleToUpdate[saveKey] = ruleDetails[saveKey];
        }

        ruleToUpdate.save(cb1);
      });
    }

    async.map(rulesToUpdate, updateRule, cb);
  }
function updateRules ( rulesToUpdate , cb ) { function updateRule ( ruleDetails , cb1 ) { var id = ruleDetails . _id ; rulesModel . findOne ( { _id : id } , function ( err , ruleToUpdate ) { if ( err ) { return cb1 ( err ) ; } if ( ruleToUpdate === null && ! options . createIfNotFound ) { return cb1 ( new Error ( "No " + ruleType + " rule matches id " + id ) ) ; } else if ( ruleToUpdate === null && options . createIfNotFound ) { ruleToUpdate = new rulesModel ( ruleDetails ) ; } for ( var saveKey in ruleDetails ) { // eslint-disable-line guard-for-in ruleToUpdate [ saveKey ] = ruleDetails [ saveKey ] ; } ruleToUpdate . save ( cb1 ) ; } ) ; } async . map ( rulesToUpdate , updateRule , cb ) ; }
process any updates
process any updates