lib/definitions/collection.js
function (id, callback) {
    if (this.isReplaying) {
      if (this.replayingVms[id]) {
        return callback(null, this.replayingVms[id]);
      }
      if (this.replayingVmsToDelete[id]) {
        var vm = new viewmodel.ViewModel({ id: id }, this.repository);
        var clonedInitValues = _.cloneDeep(this.modelInitValues);
        for (var prop in clonedInitValues) {
          if (!vm.has(prop)) {
            vm.set(prop, clonedInitValues[prop]);
          }
        }
        this.replayingVms[vm.id] = vm;
        return callback(null, this.replayingVms[id]);
      }
    }
    var self = this;
    this.repository.get(id, function(err, vm) {
      if (err) {
        debug(err);
        return callback(err);
      }
      if (!vm) {
        err = new Error('No vm object returned!');
        debug(err);
        return callback(err);
      }
      var clonedInitValues = _.cloneDeep(self.modelInitValues);
      for (var prop in clonedInitValues) {
        if (!vm.has(prop)) {
          vm.set(prop, clonedInitValues[prop]);
        }
      }
      if (self.isReplaying) {
        if (!self.replayingVms[vm.id]) {
          self.replayingVms[vm.id] = vm;
        }
        return callback(null, self.replayingVms[vm.id]);
      }
      callback(null, vm);
    });
  }
function (id, callback) {
    if (this.isReplaying) {
      if (this.replayingVms[id]) {
        return callback(null, this.replayingVms[id]);
      }
      if (this.replayingVmsToDelete[id]) {
        var vm = new viewmodel.ViewModel({ id: id }, this.repository);
        var clonedInitValues = _.cloneDeep(this.modelInitValues);
        for (var prop in clonedInitValues) {
          if (!vm.has(prop)) {
            vm.set(prop, clonedInitValues[prop]);
          }
        }
        this.replayingVms[vm.id] = vm;
        return callback(null, this.replayingVms[id]);
      }
    }
    var self = this;
    this.repository.get(id, function(err, vm) {
      if (err) {
        debug(err);
        return callback(err);
      }
      if (!vm) {
        err = new Error('No vm object returned!');
        debug(err);
        return callback(err);
      }
      var clonedInitValues = _.cloneDeep(self.modelInitValues);
      for (var prop in clonedInitValues) {
        if (!vm.has(prop)) {
          vm.set(prop, clonedInitValues[prop]);
        }
      }
      if (self.isReplaying) {
        if (!self.replayingVms[vm.id]) {
          self.replayingVms[vm.id] = vm;
        }
        return callback(null, self.replayingVms[vm.id]);
      }
      callback(null, vm);
    });
  }
function ( id , callback ) { if ( this . isReplaying ) { if ( this . replayingVms [ id ] ) { return callback ( null , this . replayingVms [ id ] ) ; } if ( this . replayingVmsToDelete [ id ] ) { var vm = new viewmodel . ViewModel ( { id : id } , this . repository ) ; var clonedInitValues = _ . cloneDeep ( this . modelInitValues ) ; for ( var prop in clonedInitValues ) { if ( ! vm . has ( prop ) ) { vm . set ( prop , clonedInitValues [ prop ] ) ; } } this . replayingVms [ vm . id ] = vm ; return callback ( null , this . replayingVms [ id ] ) ; } } var self = this ; this . repository . get ( id , function ( err , vm ) { if ( err ) { debug ( err ) ; return callback ( err ) ; } if ( ! vm ) { err = new Error ( 'No vm object returned!' ) ; debug ( err ) ; return callback ( err ) ; } var clonedInitValues = _ . cloneDeep ( self . modelInitValues ) ; for ( var prop in clonedInitValues ) { if ( ! vm . has ( prop ) ) { vm . set ( prop , clonedInitValues [ prop ] ) ; } } if ( self . isReplaying ) { if ( ! self . replayingVms [ vm . id ] ) { self . replayingVms [ vm . id ] = vm ; } return callback ( null , self . replayingVms [ vm . id ] ) ; } callback ( null , vm ) ; } ) ; }
Loads a viewModel object by id.
@param {String}   id       The viewModel id.
@param {Function} callback The function, that will be called when the this action is completed.
`function(err, vm){}` vm is of type Object
Loads a viewModel object by id .