Is there a way to aggregate data when the values of the data to be
aggregated is unknown?
I'm curious to know if there is a way to create computed properties
without having specific knowledge of the values of the properties to be
computed. For example, if I have the following model:
TR.location = DS.Model.extend({
name: DS.attr('string'),
city: DS.attr('string'),
state: DS.attr('string'),
type: DS.attr('string')
});
with the following fixtures:
TR.location.FIXTURES = [
{ id: 1, name: 'The Four Seasons', city: 'New York', state: 'NY',
type: 'Restaurant' },
{ id: 2, name: 'Le Cirque', city: 'New York', state: 'NY', type:
'Restaurant' },
{ id: 3, name: 'The Russian Tea Room', city: 'New York', state: 'NY',
type: 'Restaurant' },
{ id: 4, name: 'The Waldorf Astoria', city: 'New York', state: 'NY',
type: 'Hotel' },
{ id: 5, name: 'The Plaza', city: 'New York', state: 'NY', type:
'Hotel' }
];
I would like to display the totals based on the 'type' property. So, with
the above information, I would like to display in my template the
following:
Restaurant: 3
Hotel: 2
The problem here is that there is no domain knowledge of what the values
of the 'type' property could be, which is why I can't figure out how to
create computed properties for the above. Any workarounds for this? Thanks
in advance.
No comments:
Post a Comment