In my application route I get the current session and user.
/routes/application.js
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel: function() {
return this.get('session').fetch().catch(function() {});
},
model () {
return this.store.findRecord('user', this.get('session.currentUser.uid'));
}
});
My models are set up like so:
/models/bet.js
import DS from 'ember-data';
export default DS.Model.extend({
created: DS.attr('date'),
user: DS.belongsTo('user', { async: false })
});
/models/user.js
import DS from 'ember-data';
export default DS.Model.extend({
email: DS.attr('string'),
firstName: DS.attr('string'),
lastName: DS.attr('string'),
bets: DS.hasMany('bet', { async: true })
});
In my /bets route I'd like to load only the bets where user == session.currentUser.uid
or a similar way to get only the bets
that belongTo
the current user.
I've tried finding the best way to do this without results.
Aucun commentaire:
Enregistrer un commentaire