Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

findHasMany doesn't accept query parameters #1311

Closed
abobwhite opened this Issue · 5 comments

3 participants

@abobwhite

Using Ember Data Latest - Canary Build as of 9/16/13

I have a model that lazy-loads its products so I don't have to GET them when I don't need them:

App.Supplier = DS.Model.extend({
  products: DS.hasMany('product', {async : true}),
});

However, on some templates, I call supplier.get('products') to show a list of that Supplier's products. The problem arises when I need to pass pagination, filter, and sorting parameters to the server from within that "get" call. I know this is possible via find('modelName', { /* query params here */} but this does not seem possible via the findHasMany which gets triggered via the "get". Is there some other way to do this? I feel like this is a very valid use-case to retrieve a filtered list of the products for a particular supplier.

Thoughts? Thanks!

@wycats
Owner

I am in principle in favor of something like this. My current idea is something like this:

// somewhere, probably in an action in your route
post.reconfigure('comments', { page: 2 })

// this notifies observers that `comments` has changed, and the configuration hash will get sent to
// `findHasMany`.
@abobwhite

Do you want some help experimenting with this solution?

@wycats
Owner

@abobwhite sure. I'd love to see an experimental PR to see what it would look like.

@wycats
Owner

@abobwhite I'm closing this, but will happily entertain a PR if one is submitted.

@wycats wycats closed this
@palimpsests

Have either of you discovered a solution for this? I have the exact same need, to send a query with a findHasMany call.

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.