Skip to content

Calling ModelArray#filter should return a FilteredModelArray #78

Closed
pixelcort opened this Issue Feb 2, 2012 · 6 comments

5 participants

@pixelcort

When calling a ModelArray instance's filter method, it should return a FilteredModelArray with the results. When the contents of the model array update, either by new model instances entering/leaving the model array or the contents of those models changing, the filtered model array should be updated accordingly.

@devinus
Ember.js member
devinus commented Feb 2, 2012

"Smart queries"

@ebryn ebryn closed this Feb 16, 2012
@ebryn ebryn reopened this Feb 16, 2012
@ebryn
Ember.js member
ebryn commented Feb 16, 2012

Oops, accidently closed.

@wycats
Ember.js member
wycats commented Feb 26, 2012

So what you're requesting is something like this:

var toms = Person.filter(function(data) {
  if (data.get('name').test(/tom/i)) { return true; }
});

var marriedToms = filter.filter(function(data) {
  if (data.get('isMarried') === true) { return true; }
});

And it would work on other kinds of ModelArrays, like associations or findAll results, right?

I should note that for findAll results you could just do a regular filter.

@pixelcort

@wycats yep; preferably on any instance DS.ModelArray or its subclasses.

@wycats
Ember.js member
wycats commented Aug 10, 2013

This seems reasonable and useful.

@wycats wycats was assigned Aug 10, 2013
@tomdale
Ember.js member
tomdale commented Nov 7, 2013

We still want this as a feature, but it's out of scope for the 1.0 release. Soon, we'll be adding feature flag infrastructure à la Ember proper. I'm going to close the issue, but once feature flags are in, we'd love a PR for this feature behind a flag.

@tomdale tomdale closed this Nov 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.