ampersand-io-collection.js
function (id, options, cb) {
    if (arguments.length !== 3) {
      cb = options;
      options = {};
    }
    var self = this;
    var model = this.get(id);
    if (model){
      return cb(null, model);
    }
    function done() {
      var model = self.get(id);
      if (model) {
        if (cb){
          cb(null, model);
        }
      } else {
        cb(new Error('not found'));
      }
    }
    if (options.all) {
      this.fetch({
        callback: done
      });
    } else {
      this.fetchById(id, cb);
    }
  }
function (id, options, cb) {
    if (arguments.length !== 3) {
      cb = options;
      options = {};
    }
    var self = this;
    var model = this.get(id);
    if (model){
      return cb(null, model);
    }
    function done() {
      var model = self.get(id);
      if (model) {
        if (cb){
          cb(null, model);
        }
      } else {
        cb(new Error('not found'));
      }
    }
    if (options.all) {
      this.fetch({
        callback: done
      });
    } else {
      this.fetchById(id, cb);
    }
  }
function ( id , options , cb ) { if ( arguments . length !== 3 ) { cb = options ; options = { } ; } var self = this ; var model = this . get ( id ) ; if ( model ) { return cb ( null , model ) ; } function done ( ) { var model = self . get ( id ) ; if ( model ) { if ( cb ) { cb ( null , model ) ; } } else { cb ( new Error ( 'not found' ) ) ; } } if ( options . all ) { this . fetch ( { callback : done } ) ; } else { this . fetchById ( id , cb ) ; } }
Get or fetch a model by Id.
Get or fetch a model by Id .