jeudi 2 avril 2015

How to efficiently specify nested relationships in ember-data?

I have a nested model as such:



var School = DS.Model.extend({
classrooms: DS.hasMany('classroom', {async: true})
});

var Classroom = DS.Model.extend({
students: DS.hasMany('student', {async: true}),
school: DS.belongsTo('school', {async: true})
});

var Student = DS.Model.extend({
name: DS.attr('string'),
classroom: DS.belongsTo('classroom', {async: true})
});


I am using firebase as a backend, and I understand it is advisable to denormalize the schema for efficiency sake. Is there any utility in explicitly specifying the relationship



var Student = DS.Model.extend({
school: DS.belongsTo('school', {async: true});
});


for the Student model, even though this is implied by each Student belonging to a Classroom and each Classroom belonging to a School?





Aucun commentaire:

Enregistrer un commentaire