lib/services/model_factory.js
function(filters) {
      filters = _.clone(filters || {});
      var endpoint = api;

      if (config.parent && !filters[config.parent.key]) {
        throw new Error("fetchAll: must supply the parent.key as a filter to fetch all entities");
      }

      if (config.parent) {
        endpoint.one(config.parent.entity, filters[config.parent.key]);
        // since the filtering is happening in the endpoint url we dont need filters
        delete filters[config.parent.key];
      }

      return endpoint
        .all(config.entity)
        .filter(filters)
        .get()
        .then(function(results) {
          return results.map(this.create);
        // }.bind(this), console.error);
        }.bind(this), function(err) {console.log(err); throw new Error(err);});
    }
function(filters) {
      filters = _.clone(filters || {});
      var endpoint = api;

      if (config.parent && !filters[config.parent.key]) {
        throw new Error("fetchAll: must supply the parent.key as a filter to fetch all entities");
      }

      if (config.parent) {
        endpoint.one(config.parent.entity, filters[config.parent.key]);
        // since the filtering is happening in the endpoint url we dont need filters
        delete filters[config.parent.key];
      }

      return endpoint
        .all(config.entity)
        .filter(filters)
        .get()
        .then(function(results) {
          return results.map(this.create);
        // }.bind(this), console.error);
        }.bind(this), function(err) {console.log(err); throw new Error(err);});
    }
function ( filters ) { filters = _ . clone ( filters || { } ) ; var endpoint = api ; if ( config . parent && ! filters [ config . parent . key ] ) { throw new Error ( "fetchAll: must supply the parent.key as a filter to fetch all entities" ) ; } if ( config . parent ) { endpoint . one ( config . parent . entity , filters [ config . parent . key ] ) ; // since the filtering is happening in the endpoint url we dont need filters delete filters [ config . parent . key ] ; } return endpoint . all ( config . entity ) . filter ( filters ) . get ( ) . then ( function ( results ) { return results . map ( this . create ) ; // }.bind(this), console.error); } . bind ( this ) , function ( err ) { console . log ( err ) ; throw new Error ( err ) ; } ) ; }
Fetches all the entities that match the supplied filters
If the model has a parent association than the parent.key must be
supplied.
@param {Object|undefined} filters (optional)
@return {Deferred}
Fetches all the entities that match the supplied filters If the model has a parent association than the parent . key must be supplied .