使用当前的ember-data 0.13有没有办法从PUT请求的响应内容更新模型?
在我的REST api字段(例如updated_at)中,在对象更新期间在服务器上设置,并且客户端模型需要使用PUT请求的响应内容进行更新。
具体来说,需要从PUT响应中设置用于并发处理的updated_at属性。
答案 0 :(得分:3)
想出来。如果REST API由于PUT请求而返回有效负载以供日后参考,则它不能在数组内。
即。这样:
{
"client": {
"__v": 2,
"_id": "51d47b5b3f7499341a00006a",
"created_at": "2013-07-03T19:28:27.868Z",
"created_by": "51d47b5b3f7499341a000003",
"name": "A1",
"updated_at": "2013-07-04T21:20:36.311Z",
"updated_by": "51d47b5b3f7499341a000004",
}
}
而不是这个:
{
"client": [
{
"__v": 2,
"_id": "51d47b5b3f7499341a00006a",
"created_at": "2013-07-03T19:28:27.868Z",
"created_by": "51d47b5b3f7499341a000003",
"name": "A1",
"updated_at": "2013-07-04T21:23:11.943Z",
"updated_by": "51d47b5b3f7499341a000004",
}
]
}