假设我有一个带有以下布局的Rails应用程序(从我的实际项目中简化了一下):
User
has many Notes
Category
has many Notes
Note
belongs to User
belongs to Category
Run Code Online (Sandbox Code Playgroud)
注释可以在以下位置获得:
/users/:user_id/notes.json
/categories/:category_id/notes.json
Run Code Online (Sandbox Code Playgroud)
但不是:
/notes.json
Run Code Online (Sandbox Code Playgroud)
在整个系统中有太多的Notes要在一个请求中向下发送 - 唯一可行的方法是仅发送必要的Notes(即,属于用户试图查看的用户或类别的Notes).
用Ember Data实现这个的最佳方法是什么?