models/card.js
export default Model.extend({
title: attr('string'),
description: attr('string'),
users: hasMany('user')
});
models/user.js
export default Model.extend({
email: attr('string'),
name: attr('string'),
cards: hasMany('card')
});
app/routes/cards.js
model() {
let user = this.store.find('user', 1)); // here user is defined
user.get('cards').then((cards) => {
console.log(cards); // here user.get('cards') is undefined
});
}
I want to get all the associated cards which are associated with the user.
Aucun commentaire:
Enregistrer un commentaire