Ember parse adapter hasMany error


#1

Hi. 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

#2

Are you sure you’re actually using the ember-parse-adapter?


#3

Yes, I see requests to the api.parse.com in my browser console and have corresponding line in my package.json


#4

Are you sure you are using the right adapter? Do you have the file app/adapter/application.js and could you tell me whats in there?


#5

No, I do not have the file app/adapter/application.js and the app/adapter(-s)/ folder.
But as far as I understand, ember-parse-adapter get started do not require this file.

Perhaps structure of my project can be of any help:

$ tree -d app
app
├── components
├── controllers
├── helpers
├── initializers
├── models
├── routes
├── services
├── styles
└── templates
    └── components

#6

Sorry I couldn’t reply earlier.

You’re correct. the addon doesn’t need it. But if you had an adapter defined from another example, it was possible you had overridden the parse adapter. The error you’re receiving looks like it is coming from ember-data (de-)serializer, while I would expect the parse addon would have its own.


#7

I haven’t have time to look into this for you, but it’s quite possible the parse addon is not compatible with the ember-data version you’re using.