findHasMany doesn't accept query parameters #1311

Closed
abobwhite opened this Issue Sep 16, 2013 · 5 comments

Comments

Projects
None yet
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

This comment has been minimized.

Show comment
Hide comment
@wycats

wycats Sep 18, 2013

Member

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`.
Member

wycats commented Sep 18, 2013

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

This comment has been minimized.

Show comment
Hide comment
@abobwhite

abobwhite Sep 18, 2013

Do you want some help experimenting with this solution?

Do you want some help experimenting with this solution?

@wycats

This comment has been minimized.

Show comment
Hide comment
@wycats

wycats Sep 22, 2013

Member

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

Member

wycats commented Sep 22, 2013

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

@wycats

This comment has been minimized.

Show comment
Hide comment
@wycats

wycats Sep 25, 2013

Member

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

Member

wycats commented Sep 25, 2013

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

@wycats wycats closed this Sep 25, 2013

@zigahertz

This comment has been minimized.

Show comment
Hide comment
@zigahertz

zigahertz Jan 21, 2015

Contributor

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

Contributor

zigahertz commented Jan 21, 2015

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