Best approach for pagination with Ember Data

Hello friends!

I am using Ember Data and I currently use store.find with params to fetch the current page. This works great but I would love to append the new page to the previous result. This however results is always server query is immutable.

I have researched a couple different solutions and I was wondering which would be best. Here are my options…feel free to add some if there is a better way of doing this.

  • Convert the query response to an array after it has been loaded
  • Drawbacks: I have to keep track of isFulfilled in my own controller…which makes the code less pretty
  • Maintain an array in the controller that each find query appends to
  • Drawbacks: Two different names for essentially the same set of data

Anyone have any suggestions/tips?

What I’ve done is in setupController toArray the record array and set that as the model. In the pagination actions, I just push to the ArrayController as you normally would. The disadvantage here is that I’m no longer operating on a record array, but I don’t see a reason for it having to remain as a record array.

Thanks Jason! That seems like a pretty solid way to do it!

Why not just use store.filter() rather than find() ?