DS.RESTAdapter的预期JSON响应的完整列表是什么? [英] What is the complete list of expected JSON responses for DS.RESTAdapter?

查看:200
本文介绍了DS.RESTAdapter的预期JSON响应的完整列表是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆