Best way to filter stores and return as a model

I read it isn’t recommended to use the ember data filter anymore and thus its been broke off into a separate addon which I ended up installing because I couldn’t figure out another solution.

So I have two questions. What should I use instead… and how would i do this with or without the data filter addon?

I’m pretty new to ember but i’ve been able to figure most of the stuff out looking at your great documentation. I’m currently using ember 2.2.

I have a promise for a supplier and it returns a record. The commented out //states works just fine, but I want to filter those results and only show states that are supported by the supplier which is resolved via a promise.

In the filter

  function(state){
      console.log(state.get('stateId') + " = " + $.inArray(state.get('stateId'), supplier.get('supportedStates')));
      return $.inArray(state.get('stateId'), supplier.get('supportedStates')); //['PA', 'NJ']); 
    }

the supplier object never gets set in time. In addition, even if I just do the hard coded states [‘PA’, ‘NJ’] it still doesn’t work or maybe it just doesn’t work in time because handlebars has already rendered everything on the page without the filter.

the full code is below:

export default Ember.Route.extend(AuthenticatedRouteMixin, {
  authManager: Ember.inject.service('session'),
  model() {
    var userId = this.get('authManager').get('userId');

    var supplier = this.store.findRecord('supplier', this.get('authManager').get('supplierId'));
    //var states = this.store.query('stateUtility', { state_active: true, utility_active: true });

    return Ember.RSVP.hash({
      rep: this.store.findRecord('supplierRep', userId),
      supplier: supplier,
      states: this.store.filter('stateUtility', { state_active: true, utility_active: true },
        function(state){
          console.log(state.get('stateId') + " = " + $.inArray(state.get('stateId'), supplier.get('supportedStates')));
          return $.inArray(state.get('stateId'), supplier.get('supportedStates')); //['PA', 'NJ']); //supplier.get('supportedStates')
        }
      )
    });
  }
});

If anyone has any ideas on how to handle this I’d really appreciate it.

Thanks!

I use ember-cli-filter-by-query

This is ok, but it doesn’t solve my problem.

I still don’t know how to filter one promise by another promise.