The store.filter API
JavaScript HTML
Switch branches/tags
Nothing to show
Clone or download

Ember Data Filter


Ember CLI

ember install ember-data-filter


To use, you will need to add this mixin to the store. If you are also using another addon which extends the store, you will want to ensure that this mixin is applied to the store provided by that addon.

//  app/services/store.js
import Store from 'ember-data/store';
import FilterMixin from 'ember-data-filter/mixins/filter';

export default Store.extend(FilterMixin);

Recommended Refactor Guide

We recommend that you refactor away from using this addon. Below is a short guide for the three filter use scenarios and how to best refactor each.

Why? Simply put, it's far more performant (and not a memory leak) for you to manage filtering yourself via a specialized computed property tailored specifically for your needs.


You can combine store.peekAll with a computed property, for instance:

// app/services/post-service.js
import Ember from 'ember';

export default Ember.Service.extend({
  store: inject.service('store'),
  init() {
    this.posts = this.get('store').peekAll('post');

  filteredPosts: Ember.computed('posts.@each.isPublished', function() {
    return this.get('posts').filterBy('isPublished');


To resolve this you will want to separate your usage of filter from your usage of query.


return store.filter(modelName, query, filter, options);

with the following if you need to wait for the query

return store.query(modelName, query, options)
  .then(() => {
    return store.filter(modelName, filter);

or the below if you do not need to wait for the query

store.query(modelName, query, options);
return store.filter(modelName, filter);


Replace store.filter(modelName) with store.peekAll(modelName).

The only difference between these two is the filter returns a promisfied RecordArray while peekAll returns a RecordArray. If during the transition you need to preserve the promise behavior, you may do the below:

return RSVP.Promise.resolve(store.peekAll(modelName));


This project is licensed under the MIT License.

Copyright (c) 2015-2018