是否有人知道重写ember-data的DS.Adapter的任何工作示例,以便一次保存所有记录?
我想将整个记录数组字符串化并将它们发送到我的服务器。我在服务器上没有太多灵活性来使用除现有API之外的任何东西,这只是一个perl CGI脚本。任何正确方向的帮助都将受到赞赏。
答案 0 :(得分:2)
我所做的是迭代ember-data模型,对它们进行序列化,将它们保存到符合服务器要求的json对象中,并执行post请求。
var identifiedResponse = []
this.store.filter(key, function (record) {
return !!record.get('name')
}).then(function(resp) {
identifiedResponse.push(item.serialize())
})
jQuery.ajax({
url: url,
type: "POST",
data: identifiedResponse,
contentType: "application/json",
dataType: 'json',
xhrFields: {
withCredentials: true
}
})