emberjs/data — pull request #273 by mathieul (2012-06-05 07:14:29+00:00)
Title: Allow to pass a query when requesting a single record using Store#find

I am implementing pagination by adding a page model wrapper. I have a list of movies that is paginated. Browsing the list of movies page by page is actually fetching a MoviePage record, its id being the page number.

The page model contains pagination related attributes (number of pages, total number of movies, etc...) as well as a hasMany relationship with the model it is paginating (movies for instance), and it works quite well.

As I want to be able to filter the list of movies on the title, I thought it would be convenient to be able to customize the single record request, so this is the goal of this pull request.

Here is to load the first page of 12 movies without a filter:

```javascript
page = MoviePage.find(1);
page.get('pages'); // => 1,615
page.get('perPage'); // => 12
page.get('total'); // => 19,380
movies = page.get('movies');
movies.get('length'); // => 10
```

And this is to load the first page of 2 movies with a filter:

```javascript
page = MoviePage.find(1, {movies: {title: "marvel"}});
page.get('pages'); // => 1
page.get('total'); // => 2
movies = page.get('movies');
movies.get('length'); // => 2
```

Since a filter is likely to change very frequently I am not using the cache for those records fetched with a customized query (by flushing the cache before reloading the object).

What do you think?

Does this approach or something similar makes sense with the design goal of ember-data?

If not what alternative would you propose?

Thanks!