I have a backend resource that contains user activities and in the application I would like to present activities based on a single day's worth of activities. I have an ArrayController called ActivitiesController defined in the router like this:
this.resource('activities', { path: '/activities/:by_date' }, function() {
this.route('new');
});
The REST API provides the following GET method:
GET /activities/[by_date]
So far this looks pretty symmetrical and achievable but I'm running into two problems:
- Parameterized array find. Typically a parameterized route would be serviced by a
ObjectControllerbut in this case theby_dateparameter simply reduces/filters the array of activities but it's still an array that's returned. I'm not sure how to structure this in the model hook in theActivitiesRouteso that its effectively doing a "findAll" rather than expecting a singular resultset. - Since functionality. As there is a reasonable network cost in bringing back these arrays of activities I would like to minimize this as much as possible and the REST API supports this by allowing for a
sinceparameter to be passed along with the date of the last request. This way the server simply responds with a304code if no records have been updated since the last call and if there are new records only the new records are returned. Is there anyway to get this "out of the box" with ember-data? Does this require building a custom Adaptor? If so, are there any open source solutions that are available?
p.s. I was thinking that part of the answer to #2 might be to incorporate Alex Speller's Query Parameters: http://discuss.emberjs.com/t/query-string-support-in-ember-router/1962/48