mardi 17 février 2015

Access Related Model

Consider the following simple models...



//models/invoices.js
export default DS.Model.extend({
created_by: DS.attr('number'), //points to a user.id
approved_by: DS.attr('number'), //also points to a user.id
});

//models/users.js
export default DS.Model.extend({
name: DS.attr('string')
});


Showing a list of invoices with the users's name field instead of their number:



# | Created | Approved
--------------------------
2 | Jim | Bobby
3 | Sue | Betty


My question: How can I also retrieve the user's name when I only have access to their id in the columns: created_by and for approved_by?


Aucun commentaire:

Enregistrer un commentaire