mercredi 21 janvier 2015

How to update model wich joined with belongsTo?

I have a Consultation model



export default DS.Model.extend({
records: DS.hasMany('record', { async: true }),
currentUser: DS.belongsTo('user'),
remoteUser: DS.belongsTo('user'),
created_time: DS.attr('number'),
freeMsgCount: function () {
return (this.get('remoteUser.msg_block')-this.get('user_msg_cnt'));
}.property('user_msg_cnt'),
.....
});


And User model



export default DS.Model.extend({
name: DS.attr('string'),
.....
});


And I try to update User model. I get json data via WebSocket



socket.on('message', function (jsonObj) {
if (jsonObj.action && jsonObj.action == 'userReload') {
self.store.push('user',jsonObj.userData );
return;
}
}


But Consultation model doesn't know about this update, because I have property freeMsgCount in Consultation model which is using data from User model this.get('remoteUser.msg_block'). User data was updated I saw it in Ember insperctor. How can I tell Consultation model to update relation remoteUser?





Aucun commentaire:

Enregistrer un commentaire