gpt4 book ai didi

ember.js - DS.RESTAdapter 的预期 JSON 响应的完整列表是什么?

转载 作者:行者123 更新时间:2023-12-02 23:44:18 24 4
gpt4 key购买 nike

我正在尝试为 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 adapter unit tests收集的并通过观察 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

例如,要填写有关批量更新响应数据的问题,L738描述预期的响应数据:

ajaxHash.success({ people: [
{ id: 1, name: "Brohuda Brokatz" },
{ id: 2, name: "Brocarl Brolerche" }
]});

关于ember.js - DS.RESTAdapter 的预期 JSON 响应的完整列表是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14922623/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com