Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hasMany error #108

Open
caracatiza opened this issue Dec 5, 2015 · 0 comments
Open

hasMany error #108

caracatiza opened this issue Dec 5, 2015 · 0 comments

Comments

@caracatiza
Copy link

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.
Could you help me to correct this error?

I use:

  • ember 1.13.7
  • ember-data 1.13.8
  • ember-parse-adapter 0.5.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant