# Best practice for multiple models per route with pagination

**URL:** https://discuss.emberjs.com/t/best-practice-for-multiple-models-per-route-with-pagination/6679
**Category:** Design
**Created:** [November 12, 2014, 4:00pm UTC](https://discuss.emberjs.com/t/best-practice-for-multiple-models-per-route-with-pagination/6679 "2014-11-12T16:00:25Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![behrendtio](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/behrendtio/32/9822_2.png) [@behrendtio](https://discuss.emberjs.com/u/behrendtio)
#### Post date: [November 12, 2014, 4:00pm UTC](https://discuss.emberjs.com/t/best-practice-for-multiple-models-per-route-with-pagination/6679/1 "2014-11-12T16:00:25Z")

</div>

I was wondering if there’s a best practice for handling multiple different models per route while using pagination. For instance:

Let’s assume I have a `car` model and an `image` model. Each `car` has many `images`. But there’s also a `house` model that has many `images`. Visiting `/houses/1` or `/cars/1` would usually get the model with the according ID from the backend (assuming ember-data here, but anyway).

Now that I need the images as well I could load them in `afterModel` or `setupController`, depending on the point in time I need them. So far so good. Now `house`/`car` are somewhat the “main” model since they are loaded into `model/content`, while the images are “on top”. But if I want to add a lazy loading like Instagram has, I’d have to paginate through the images. Again, possible, but kinda problematic to implement in a general way, plus it breaks most pagination addons.

Discourse if currently loading both the topic and it’s posts in the model hook, saving the data directly on the topic instead of on the controller or route.

Long story short: Would it be good/preferable to make the images the “main” model and load the `house`/`car` as the “on top” model or the other way around or discourse’s version or something totally different.

This is especially interesting for API’s that don’t support ember-data’s way of loading hasMany relationships.

I’m also interested in how you guys handle pagination with filtered arrays, e.g. `this.store.find('image', { car: car, offset: offset })` in a nice and general way. Currently I get the `query` object from the array and merge it with my offset/page parameters to update the array using a backend call.

Curios about your opinions!

Btw, related: [Best practice to get multiple data from route before the view rendering? - #4 by denisnazarov](http://discuss.emberjs.com/t/best-practice-to-get-multiple-data-from-route-before-the-view-rendering/3016/4)
