我正在尝试为 Ember.js 应用程序编写基于 express.js 的自定义服务器。我相处得很好,但我一直在试图猜测 Ember Data 在给定时刻期望什么 JSON 响应。
这个全新的文档是一个很好的开始http://emberjs.com/guides/models/the-rest-adapter/但还不够完整。
我在黑暗中的刺伤让我明白(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 ??? ???
有人可以帮我填一些这些空白吗?
编辑,预期 JSON 响应的完整列表
这些响应是从ember-data REST 适配器单元测试和通过查看Example Ember Data 应用程序上的网络流量收集的。
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]}