我正在使用带有 ember-data 1.0 和 ember.js 1.0 的休息适配器
给定这些模型:
App.Customer = DS.Model.extend({
name: DS.attr('string'),
state: DS.belongsTo("State")
});
App.State = DS.Model.extend({
region: DS.attr('string'),
state: DS.attr('string'),
stateName: DS.attr('string'),
customers: DS.hasMany("Customer")
});
当我去 /#/states 时,我得到这个 json 响应
{
"states": [
{
"region": "West",
"state": "AZ",
"stateName": "Arizona",
"id": "0x0000000000000324",
"customers": [
"0x00000000000001e5"
]
},
{
"region": "West",
"state": "CA",
"stateName": "California",
"id": "0x0000000000000325",
"customers": [
"0x00000000000001c0",
"0x00000000000001c4",
"0x00000000000001d4"
]
}
]
"customers" : [
{
}
]
}
现在,我有几个问题
1)我应该在客户部分放什么?所有客户的完整列表,或者只是州列表中指定的客户列表?
2) 如果我访问 /#/customers 我应该发回什么数据?
3) 如果我要编辑客户。我会设置它以便查找/组合向服务器发出单独的请求吗?
谢谢您的帮助 !