carboncomputed
carboncomputed

Reputation: 1620

How do you limit results from a findAll in ember.js?

My api takes query parameters such as "page". This is to limit the number items sent over. I realize you can filter these with ember once they've already been retrieved, but I want this app to scale. This means I can't be receiving large amounts of data over the wire like findAll already does. How would I go about doing this in ember? Where should I put my custom ajax? I still would like to use most of the features ember has like the ability to watch my models.

Upvotes: 0

Views: 1356

Answers (2)

Sherwin Yu
Sherwin Yu

Reputation: 3230

Perhaps I misunderstand your question, but you can use App.Model.findQuery and pass it query string parameters, which will be sent to your server.

For example: App.Model.findQuery({page: 5, color: 'blue'}). Of course it's up to your API to implement the response to the query params.

See also: what's the difference between find, findAll and findQuery in ember-data findQuery source

Upvotes: 1

intuitivepixel
intuitivepixel

Reputation: 23322

This sounds like you want pagination support, but lamentably this feature is still not implemented in ember core. However some folks have already created pagination support to work with ember, one very good example is from Toran Billups, have a look here: https://github.com/toranb/ember-pagination-example. Have also a look here for a good answer explaining it's implementation: Ember pagination full example

Hope it helps.

Upvotes: 1

Related Questions