1
在上parse.com數據庫我有一個表Item
具有以下字段:燼解析適配器的hasMany錯誤
"objectId": "O0NkhZAcMd",
"price": "100",
"topping": [
{
"__type": "Pointer",
"className": "Topping",
"objectId": "iKbMWHZrEB"
},
{
"__type": "Pointer",
"className": "Topping",
"objectId": "yIIkePYKSS"
},
{
"__type": "Pointer",
"className": "Topping",
"objectId": "lZJ4Kpqodf"
},
...
]
摘心有場title
和price
。
對於這個數據庫,我有以下型號:
應用程序/模型/ item.js:
import DS from 'ember-data';
export default DS.Model.extend({
objectId: DS.attr(),
price: DS.attr(),
topping: DS.hasMany('topping', {async: true}),
});
應用程序/模型/ topping.js:
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
- 燼-解析適配器0.5.3