Ember.js ember解析适配器有许多错误
在parse.com上的数据库中,我有一个带有以下字段的表Ember.js ember解析适配器有许多错误,ember.js,parse-platform,ember-data,Ember.js,Parse Platform,Ember Data,在parse.com上的数据库中,我有一个带有以下字段的表Item: "objectId": "O0NkhZAcMd", "price": "100", "topping": [ { "__type": "Pointer", "className": "Topping", "objectId": "iKbMWHZrEB" }, { "__type": "Pointer", "className
Item
:
"objectId": "O0NkhZAcMd",
"price": "100",
"topping": [
{
"__type": "Pointer",
"className": "Topping",
"objectId": "iKbMWHZrEB"
},
{
"__type": "Pointer",
"className": "Topping",
"objectId": "yIIkePYKSS"
},
{
"__type": "Pointer",
"className": "Topping",
"objectId": "lZJ4Kpqodf"
},
...
]
Topping有一个字段title
和price
对于该数据库,我有以下模型: app/models/item.js:
import DS from 'ember-data';
export default DS.Model.extend({
objectId: DS.attr(),
price: DS.attr(),
topping: DS.hasMany('topping', {async: true}),
});
import DS from 'ember-data';
export default DS.Model.extend({
objectId: DS.attr(),
price: DS.attr(),
title: DS.attr(),
});
app/models/topping.js:
import DS from 'ember-data';
export default DS.Model.extend({
objectId: DS.attr(),
price: DS.attr(),
topping: DS.hasMany('topping', {async: true}),
});
import DS from 'ember-data';
export default DS.Model.extend({
objectId: DS.attr(),
price: DS.attr(),
title: DS.attr(),
});
在app/models/item.js
中添加topping:DS.hasMany('topping',{async:true})
时,我开始出现以下错误:
Error while processing route: menu Assertion Failed: Ember Data expected a number or string to represent the record(s) in the `topping` relationship instead it found an object. If this is a polymorphic relationship please specify a `type` key. If this is an embedded relationship please include the `DS.EmbeddedRecordsMixin` and specify the `topping` property in your serializer's attrs object.
我不知道需要指定哪种类型以及在哪里执行。有人能帮我吗 我使用:
- 余烬1.13.7
- 余烬数据1.13.8
- ember解析适配器0.5.3
所属关系添加到您的顶级
模型中
import DS from 'ember-data';
export default DS.Model.extend({
objectId: DS.attr(),
price: DS.attr(),
title: DS.attr(),
item: DS.belongsTo('item', { async: true })
});
尝试将归属\u to
关系添加到您的topping
模型中
import DS from 'ember-data';
export default DS.Model.extend({
objectId: DS.attr(),
price: DS.attr(),
title: DS.attr(),
item: DS.belongsTo('item', { async: true })
});