lib/definitions/collection.js
function (vm, callback) {
    if (this.isReplaying) {
      vm.actionOnCommitForReplay = vm.actionOnCommit;
      // Clone the values to be sure no reference mistakes happen!
      if (vm.attributes) {
        var flatAttr = flatten(vm.attributes);
        var undefines = [];
        _.each(flatAttr, function (v, k) {
          if (v === undefined) {
            undefines.push(k);
          }
        });
        vm.attributes = vm.toJSON();
        _.each(undefines, function (k) {
          vm.set(k, undefined);
        });
      }

      this.replayingVms[vm.id] = vm;
      if (vm.actionOnCommit === 'delete') {
        delete this.replayingVms[vm.id];
        if (!this.replayingVmsToDelete[vm.id]) this.replayingVmsToDelete[vm.id] = vm;
      }
      if (vm.actionOnCommit === 'create') {
        vm.actionOnCommit = 'update';
      }
      return callback(null);
    }
    this.repository.commit(vm, callback);
  }
function (vm, callback) {
    if (this.isReplaying) {
      vm.actionOnCommitForReplay = vm.actionOnCommit;
      // Clone the values to be sure no reference mistakes happen!
      if (vm.attributes) {
        var flatAttr = flatten(vm.attributes);
        var undefines = [];
        _.each(flatAttr, function (v, k) {
          if (v === undefined) {
            undefines.push(k);
          }
        });
        vm.attributes = vm.toJSON();
        _.each(undefines, function (k) {
          vm.set(k, undefined);
        });
      }

      this.replayingVms[vm.id] = vm;
      if (vm.actionOnCommit === 'delete') {
        delete this.replayingVms[vm.id];
        if (!this.replayingVmsToDelete[vm.id]) this.replayingVmsToDelete[vm.id] = vm;
      }
      if (vm.actionOnCommit === 'create') {
        vm.actionOnCommit = 'update';
      }
      return callback(null);
    }
    this.repository.commit(vm, callback);
  }
function ( vm , callback ) { if ( this . isReplaying ) { vm . actionOnCommitForReplay = vm . actionOnCommit ; // Clone the values to be sure no reference mistakes happen! if ( vm . attributes ) { var flatAttr = flatten ( vm . attributes ) ; var undefines = [ ] ; _ . each ( flatAttr , function ( v , k ) { if ( v === undefined ) { undefines . push ( k ) ; } } ) ; vm . attributes = vm . toJSON ( ) ; _ . each ( undefines , function ( k ) { vm . set ( k , undefined ) ; } ) ; } this . replayingVms [ vm . id ] = vm ; if ( vm . actionOnCommit === 'delete' ) { delete this . replayingVms [ vm . id ] ; if ( ! this . replayingVmsToDelete [ vm . id ] ) this . replayingVmsToDelete [ vm . id ] = vm ; } if ( vm . actionOnCommit === 'create' ) { vm . actionOnCommit = 'update' ; } return callback ( null ) ; } this . repository . commit ( vm , callback ) ; }
Save the passed viewModel object in the read model.
@param {Object}   vm       The viewModel object.
@param {Function} callback The function, that will be called when the this action is completed. [optional]
`function(err){}`
Save the passed viewModel object in the read model .