vendredi 9 janvier 2015

hasMany does not load in ember data beta 14 when all the data is preloaded

I have a model with hierarchical relation like this:



App.Question=DS.Model.extend({
name:DS.attr('string'),
childQuestions:DS.hasMany('question',{async:true}),
parentQuestion:DS.attr('string')
});


My payload looks like this :



"questions":[
{
id:1,
name:'question 1',
childQuestions:[]
},
{
id:2,
name:'question 2',
childQuestions:[3]
},
{
id:3,
name:'question 3',
childQuestions:[],
parentQuestion:2
}
]


before with ember 1.5 and ember data beta 3, I was able to do :



var q = model.findBy('id','2');
console.log(q);
console.log(q.get('childQuestions'));//would give me the child questions


but the same returns empty promise array that has nothing even when it resolves!!


Here is the jsbins with ember 1.5 and data beta 3 : http://ift.tt/1BW2zVg Here is the one where things are not working for me : http://ift.tt/1BW2zVk


I could probably try out "EmbeddedRecordsMixin" but at this point we don't want to change anything in the rest api itself.


Your help will be highly appreciated. Thanks.


Aucun commentaire:

Enregistrer un commentaire