How to architecture filtering and sorting with relationships in Ember Data?


#1

What would be the best way to architect following structure in Ember with Ember Data. In Ember Data the relationship would be as follows:

shop

name: attr('string');    
products: belongsTo('product');

product

name: attr('string');    
shop: hasMany('shop');
  1. I would like to sort parent (shops) based on sort properties, but also be able to sort the relationship (products) based on their own sort properties.

  2. I would like to filter both of the results based on a "name" property each have. Previously I did this with regexp & RSVP, but this caused issues with using itemController. The context would change, as I had an array of objects returned from the RSVP promise.

Would be better to change controller content and to do this filtering & sorting on the backend by using querystring parameters? Or would be better to have different controllers for both shops and products?

If there are some examples where this kind of functionality is done, I would greatly appreciate them, but even discussion on how this should be done would be beneficial. I have not seen a lot discussion on how to achieve this kind of functionality.