Javascript Ember Data 2.1.0忽略我的JSON响应中的links属性
Ember Data 2.1.0忽略我的JSON响应中的links属性,并触发以下请求:Javascript Ember Data 2.1.0忽略我的JSON响应中的links属性,javascript,ember.js,ember-data,Javascript,Ember.js,Ember Data,Ember Data 2.1.0忽略我的JSON响应中的links属性,并触发以下请求: /point_logs/3e5ff053422f40e3a8057fc5e8100c47 对于找到的每个点日志,它也会触发一个请求。相反,我希望它获取所有点日志的集合 不过,在Ember 1.x中,一切都很好。我到处寻找答案,但不幸的是,到目前为止我还没有找到解决办法 设备型号 var DirectObject = DS.Model.extend({ name: DS.attr('string')
/point_logs/3e5ff053422f40e3a8057fc5e8100c47
对于找到的每个点日志,它也会触发一个请求。相反,我希望它获取所有点日志的集合
不过,在Ember 1.x中,一切都很好。我到处寻找答案,但不幸的是,到目前为止我还没有找到解决办法
设备型号
var DirectObject = DS.Model.extend({
name: DS.attr('string'),
description: DS.attr('string'),
type: DS.attr('string'),
createdDate: DS.attr('date'),
modifiedDate: DS.attr('date'),
deletedDate: DS.attr('date'),
pointLog: DS.belongsTo('pointLog')
});
var PointLog = DS.Model.extend({
unit: DS.attr('string'),
type: DS.attr('string'),
lastConsecutiveLogDate: DS.attr('date'),
updatedDate: DS.attr('date'),
directObject: DS.belongsTo('directObject')
});
点日志模型
var DirectObject = DS.Model.extend({
name: DS.attr('string'),
description: DS.attr('string'),
type: DS.attr('string'),
createdDate: DS.attr('date'),
modifiedDate: DS.attr('date'),
deletedDate: DS.attr('date'),
pointLog: DS.belongsTo('pointLog')
});
var PointLog = DS.Model.extend({
unit: DS.attr('string'),
type: DS.attr('string'),
lastConsecutiveLogDate: DS.attr('date'),
updatedDate: DS.attr('date'),
directObject: DS.belongsTo('directObject')
});
JSON响应
{
"data": [
{
"id": "6dbcf32a3e064a36a1db4847329cc90d",
"type": "appliance",
"attributes": {
"name": "3974737",
"description": "",
"type": "zz_misc",
"createdDate": "2015-09-15T14:23:02.768Z",
"modifiedDate": "2015-10-08T08:39:15.525Z",
"deletedDate": null
},
"relationships": {
"pointLog": {
"data": {
"id": "3e5ff053422f40e3a8057fc5e8100c47",
"type": "pointLog"
},
"links": {
"related": "/core/appliances/6dbcf32a3e064a36a1db4847329cc90d/point_log"
}
}
}
}
],
"included": [],
"links": {
"self": "/core/appliances"
}
}
"relationships": {
"pointLog": {
"data": {
"id": "3e5ff053422f40e3a8057fc5e8100c47",
"type": "pointLog"
},
"links": {
"related": "/core/appliances/6dbcf32a3e064a36a1db4847329cc90d/point_log"
}
}
}
我还尝试使用self属性而不是related属性。并且还与一个对象相关,其中的href属性是url。好的,所以我找到了它。问题在于数据属性。如果它存在,Ember将进行单独调用,而不使用links对象中给出的url 之前
{
"data": [
{
"id": "6dbcf32a3e064a36a1db4847329cc90d",
"type": "appliance",
"attributes": {
"name": "3974737",
"description": "",
"type": "zz_misc",
"createdDate": "2015-09-15T14:23:02.768Z",
"modifiedDate": "2015-10-08T08:39:15.525Z",
"deletedDate": null
},
"relationships": {
"pointLog": {
"data": {
"id": "3e5ff053422f40e3a8057fc5e8100c47",
"type": "pointLog"
},
"links": {
"related": "/core/appliances/6dbcf32a3e064a36a1db4847329cc90d/point_log"
}
}
}
}
],
"included": [],
"links": {
"self": "/core/appliances"
}
}
"relationships": {
"pointLog": {
"data": {
"id": "3e5ff053422f40e3a8057fc5e8100c47",
"type": "pointLog"
},
"links": {
"related": "/core/appliances/6dbcf32a3e064a36a1db4847329cc90d/point_log"
}
}
}
之后
"relationships": {
"pointLog": {
"links": {
"related": "/core/appliances/6dbcf32a3e064a36a1db4847329cc90d/point_log"
}
}
}
设备扩展了DirectObject模型如何提供数据?它是异步的吗?澄清一下:您想为每个设备返回多个
点日志吗?或者反之亦然?@sbatson5调用是异步的,实际上我想为每个设备返回多个点日志。