dimanche 6 décembre 2015

ember parse adapter hasMany error

In the database on the parse.com I have a table Item with the following fields:

"objectId": "O0NkhZAcMd",
"price": "100",
"topping": [
    {
        "__type": "Pointer",
        "className": "Topping",
        "objectId": "iKbMWHZrEB"
    },
    {
        "__type": "Pointer",
        "className": "Topping",
        "objectId": "yIIkePYKSS"
    },
    {
        "__type": "Pointer",
        "className": "Topping",
        "objectId": "lZJ4Kpqodf"
    },
...
]

Topping has a field title and price.
For this database I have the following models:

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}),
}); 

app/models/topping.js:

import DS from 'ember-data';

export default DS.Model.extend({
  objectId: DS.attr(),
  price: DS.attr(),
  title: DS.attr(),
});

When I added topping: DS.hasMany('topping', {async: true}) in app/models/item.js I started getting the following error:

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.

I do not know what type I need to specify and where to do it.
May be anybody can help me?

I use:

  • ember 1.13.7
  • ember-data 1.13.8
  • ember-parse-adapter 0.5.3



Aucun commentaire:

Enregistrer un commentaire