Ember.js: Calculate the sum of a property of all child models
问题 My application has the following models: App.Store = DS.Store.extend({ revision: 11, adapter: 'DS.FixtureAdapter' }); App.List = DS.Model.extend({ name: DS.attr('string'), users: DS.hasMany('App.User'), tweetsUnread: function(){ ///////////////////////////////////////// // Code to dynamically calculate the sum // of tweetsUnread property of all // App.User that are related to this list ///////////////////////////////////////// } }); App.User = DS.Model.extend({ screenName: DS.attr('string'),