lib/definitions/collection.js
function (callback) {
    if (!this.isReplaying) {
      var err = new Error('Not in replay mode!');
      debug(err);
      return callback(err);
    }
    var replVms = _.values(this.replayingVms);
    var replVmsToDelete = _.values(this.replayingVmsToDelete);
    var self = this;

    function commit (vm, callback) {
      if (!vm.actionOnCommitForReplay) {
        return callback(null);
      }
      vm.actionOnCommit = vm.actionOnCommitForReplay;
      delete vm.actionOnCommitForReplay;
      self.repository.commit(vm, function (err) {
        if (err) {
          debug(err);
          debug(vm);
        }
        callback(err);
      });
    }

    function prepareVmsForBulkCommit (vms) {
      return _.map(_.filter(vms, function(vm) { return vm.actionOnCommitForReplay }), function (vm) {
        vm.actionOnCommit = vm.actionOnCommitForReplay;
        delete vm.actionOnCommitForReplay;
        return vm;
      })
    }

    function bulkCommit (vms, callback) {
      if (vms.length === 0) return callback(null);
      self.repository.bulkCommit(prepareVmsForBulkCommit(vms), function (err) {
        if (err) {
          debug(err);
        }
        callback(err);
      });
    }

    async.series([
      function (callback) {
        if (self.repository.bulkCommit) {
          return bulkCommit(replVmsToDelete, callback);
        }
        async.each(replVmsToDelete, commit, callback);
      },
      function (callback) {
        if (self.repository.bulkCommit) {
          return bulkCommit(replVms, callback);
        }
        async.each(replVms, commit, callback);
      }
    ], function (err) {
      if (err) {
        debug(err);
      }
      self.replayingVms = {};
      self.replayingVmsToDelete = {};
      self.isReplaying = false;
      callback(err);
    });
  }
function (callback) {
    if (!this.isReplaying) {
      var err = new Error('Not in replay mode!');
      debug(err);
      return callback(err);
    }
    var replVms = _.values(this.replayingVms);
    var replVmsToDelete = _.values(this.replayingVmsToDelete);
    var self = this;

    function commit (vm, callback) {
      if (!vm.actionOnCommitForReplay) {
        return callback(null);
      }
      vm.actionOnCommit = vm.actionOnCommitForReplay;
      delete vm.actionOnCommitForReplay;
      self.repository.commit(vm, function (err) {
        if (err) {
          debug(err);
          debug(vm);
        }
        callback(err);
      });
    }

    function prepareVmsForBulkCommit (vms) {
      return _.map(_.filter(vms, function(vm) { return vm.actionOnCommitForReplay }), function (vm) {
        vm.actionOnCommit = vm.actionOnCommitForReplay;
        delete vm.actionOnCommitForReplay;
        return vm;
      })
    }

    function bulkCommit (vms, callback) {
      if (vms.length === 0) return callback(null);
      self.repository.bulkCommit(prepareVmsForBulkCommit(vms), function (err) {
        if (err) {
          debug(err);
        }
        callback(err);
      });
    }

    async.series([
      function (callback) {
        if (self.repository.bulkCommit) {
          return bulkCommit(replVmsToDelete, callback);
        }
        async.each(replVmsToDelete, commit, callback);
      },
      function (callback) {
        if (self.repository.bulkCommit) {
          return bulkCommit(replVms, callback);
        }
        async.each(replVms, commit, callback);
      }
    ], function (err) {
      if (err) {
        debug(err);
      }
      self.replayingVms = {};
      self.replayingVmsToDelete = {};
      self.isReplaying = false;
      callback(err);
    });
  }
function ( callback ) { if ( ! this . isReplaying ) { var err = new Error ( 'Not in replay mode!' ) ; debug ( err ) ; return callback ( err ) ; } var replVms = _ . values ( this . replayingVms ) ; var replVmsToDelete = _ . values ( this . replayingVmsToDelete ) ; var self = this ; function commit ( vm , callback ) { if ( ! vm . actionOnCommitForReplay ) { return callback ( null ) ; } vm . actionOnCommit = vm . actionOnCommitForReplay ; delete vm . actionOnCommitForReplay ; self . repository . commit ( vm , function ( err ) { if ( err ) { debug ( err ) ; debug ( vm ) ; } callback ( err ) ; } ) ; } function prepareVmsForBulkCommit ( vms ) { return _ . map ( _ . filter ( vms , function ( vm ) { return vm . actionOnCommitForReplay } ) , function ( vm ) { vm . actionOnCommit = vm . actionOnCommitForReplay ; delete vm . actionOnCommitForReplay ; return vm ; } ) } function bulkCommit ( vms , callback ) { if ( vms . length === 0 ) return callback ( null ) ; self . repository . bulkCommit ( prepareVmsForBulkCommit ( vms ) , function ( err ) { if ( err ) { debug ( err ) ; } callback ( err ) ; } ) ; } async . series ( [ function ( callback ) { if ( self . repository . bulkCommit ) { return bulkCommit ( replVmsToDelete , callback ) ; } async . each ( replVmsToDelete , commit , callback ) ; } , function ( callback ) { if ( self . repository . bulkCommit ) { return bulkCommit ( replVms , callback ) ; } async . each ( replVms , commit , callback ) ; } ] , function ( err ) { if ( err ) { debug ( err ) ; } self . replayingVms = { } ; self . replayingVmsToDelete = { } ; self . isReplaying = false ; callback ( err ) ; } ) ; }
Saves all replaying viewmodels.
@param {Function} callback The function, that will be called when the this action is completed.
`function(err){}`
Saves all replaying viewmodels .