我正在尝试手动将数据加载到存储中。这是 jsBin 的链接http://jsbin.com/uYUsuTu/1/edit?html,output
我的模型定义为:
AS.AnalyticsRun = DS.Model.extend({
'exerciseId': DS.attr('number'),
'exerciseRunId': DS.attr('number'),
'evolutionRunIds': DS.attr('string'),
'analyticsTemplateId': DS.attr('number'),
'analyticsPlan': DS.attr('string'),
'commandScript': DS.attr('string'),
'queued': DS.attr('boolean'),
'final': DS.attr('boolean'),
'createdBy': DS.attr('string'),
'dateCreated': DS.attr('date'),
'lastUpdatedBy': DS.attr('string'),
'lastUpdated': DS.attr('date'),
'analyticsRunParameters': DS.attr('string'),
'evolutionRuns': DS.hasMany('evolutionRun')
});
我正在尝试将数据加载到存储中,例如:
var run = {"analyticsRun": [{"id": 2,
"exerciseId": 1885,
"exerciseRunId": 1938,
"evolutionRunIds": null,
"analyticsTemplateId": 13,
"analyticsPlan": null,
"commandScript": "test",
"queued": false,
"final": false,
"createdBy": "Deewendra Shrestha",
"dateCreated": "2013-10-04T13:40:23Z",
"lastUpdatedBy": "Deewendra Shrestha",
"lastUpdated": "2013-10-04T13:40:23Z",
"analyticsRunParameters": null,
"evolutionRuns": []}],
"evolutionRuns": [
{"id": 1378, "name": "aff_parameters_dannon.Pretest.Dannon_pman_KK2"},
{"id": 1375, "name": "aff_parameters_dannon.Pretest.Dannon_pman_KM1"},
{"id": 1377, "name": "aff_parameters_dannon.Pretest.Dannon_pman_KM2"},
{"id": 1371, "name": "aff_parameters_dannon.Pretest.Dannon_pman_control"},
{"id": 1376, "name": "aff_parameters_dannon.Pretest.Dannon_pman_KK1"}
]};
this.get('store').push('analyticsRun', run);
我得到错误
您必须id
在传递给的哈希中包含一个push
不知道我在这里做错了什么!
谢谢,迪