0
은 내가 상담 모델belongsTo와 조인 된 모델을 업데이트하는 방법은 무엇입니까?
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'),
.....
});
및 사용자 모델
export default DS.Model.extend({
name: DS.attr('string'),
.....
});
을하고 난 사용자 모델을 업데이트하려고합니다. 나는 웹 소켓
socket.on('message', function (jsonObj) {
if (jsonObj.action && jsonObj.action == 'userReload') {
self.store.push('user',jsonObj.userData);
return;
}
}
를 통해 JSON 데이터를 얻을하지만 사용자 모델 this.get('remoteUser.msg_block')
의 데이터를 사용 상담 모델의 특성 freeMsgCount
을 가지고 있기 때문에 상담 모델이 업데이트에 대해 알고하지 않습니다. 사용자 데이터가 업데이트되었습니다. Ember insperctor에서 보았습니다. 관계 remoteUser를 업데이트하기 위해 Consultation 모델을 어떻게 말할 수 있습니까?
흠, 'remoteUser'' 만 추가하려고했으나 작동하지 않았습니다. 이제''remoteUser.msg_block ''을 추가하고 잘 작동합니다. – Dmitro
AFAIK'remoteUser'는 전체 개체가 변경 될 때만 트리거됩니다. –