DS.RESTAdapter 的预期 JSON 响应的完整列表是什么? [英] What is the complete list of expected JSON responses for DS.RESTAdapter?
问题描述
我正在尝试为 Ember.js 应用程序编写一个基于 express.js 的自定义服务器.我相处得很好,但我一直在尝试猜测 Ember Data 在给定时刻期望什么 JSON 响应.
I am attempting to write a custom express.js based server for an Ember.js app. I am getting along fairly well but I'm constantly getting stuck trying to guess what JSON responses Ember Data is expecting at a given moment.
这个全新的文档是一个很好的开始 http://emberjs.com/guides/models/the-rest-adapter/ 但不够完整.
This brand new documentation is a great start http://emberjs.com/guides/models/the-rest-adapter/ but not complete enough.
我在黑暗中的刺伤让我明白(Ember pre4,Ember Data 11):
My stabbing in the dark has lead me to understand (Ember pre4, Ember Data 11):
Context Server URL Method Req. Data Resp. Data
~~~~~~~ ~~~~~~~~~~ ~~~~~~ ~~~~~~~~~ ~~~~~~~~~~
Getting a list of all users /users GET {"users":[{...},{...}]}
Getting a particular user /users/123 GET {"user":{...}}
Creating a user /users POST {"user":{...}} ???
Updating a user /users/123 PUT {"user":{...}} ???
Deleting a user /users/123 DELETE ??? ???
Creating a user (bulkUpdate) /users POST {"users":[{...},{...}]} ???
Updating a user (bulkUpdate) /users/bulk PUT {"users":[{...},{...}]} ???
Deleting a user (bulkUpdate) /users/123 DELETE ??? ???
有人可以帮我填写其中的一些空白吗?
Can someone help me fill in some of these blanks?
编辑,预期 JSON 响应的完整列表
这些响应来自 ember-data REST 适配器单元测试并通过在示例 Ember 数据应用上观察网络流量.
These responses were gleaned from the ember-data REST adapter unit tests and by watching the network traffic on the Example Ember Data app.
Context Server URL Method Req. Data Resp. Data
~~~~~~~ ~~~~~~~~~~ ~~~~~~ ~~~~~~~~~ ~~~~~~~~~~
Getting a list of all users /users GET {"users":[{...},{...}]}
Getting a particular user /users/123 GET {"user":{...}}
Creating a user /users POST {"user":{...}} {"user":{...}}
Updating a user /users/123 PUT {"user":{...}} {"user":{...}}
Deleting a user /users/123 DELETE N/A null
Creating a user (bulkCommit) /users POST {"users":[{...},{...}]} {"users":[{...},{...}]}
Updating a user (bulkCommit) /users/bulk PUT {"users":[{...},{...}]} {"users":[{...},{...}]}
Deleting a user (bulkCommit) /users/bulk DELETE {"users":[1,2]} {"users":[1,2]}
推荐答案
与其在黑暗中刺痛,不如看看 rest-adapter-test
Instead of stabbing in the dark, have a look at rest-adapter-test
例如,要填写有关批量更新的响应数据的问题,L738 描述了预期的响应数据:
For example, to fill in your question on response data for bulk updates, L738 describes the expected response data:
ajaxHash.success({ people: [
{ id: 1, name: "Brohuda Brokatz" },
{ id: 2, name: "Brocarl Brolerche" }
]});
这篇关于DS.RESTAdapter 的预期 JSON 响应的完整列表是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!