EmberJS Data HasMany relationship parent JSON contains whole object not ids
App.Message = someParentClass.extend({
childMessages: DS.hasMany('ChildMessage'),
message:DS.attr('string',{defaultValue: ""})
}
App.ChildMessage = someParentClass.extend({
message: DS.attr('string',{defaultValue: ""}),
code:DS.attr('string',{defaultValue: ""})
}
and the JSON looks like this
{
"message":"xyz",
"childMessages":[{"code":"we","message":""},{"code":"uh","message":""},{"code":"wd","message":""}]
}
after fetching the object, code and message for child messages are undefined (not getting populated)
changing JSON in not in my hand
Please help
The problem got resolved.
Ember requirs id for each child objects. So from server I added id files with random number.
{
"message":"xyz",
"childMessages":[{"id":4567,"code":"we","message":""},{"id":7874,"code":"uh","message":""},{"id":5231,"code":"wd","message":""}]
}
it worked
Thanks