Closed Beef-Tech closed 3 years ago
Hello
@Computed()
public get sum(): number {
const snapshot = this.snapshot;
return snapshot.ids.reduce((sum: number, id: number) => {
return sum + snapshot.entities[id]. receivedAmount;
}, 0);
}
Thanks, But if I would like to group by a given parameter like "program", how Can I do ?
Thanks.
Hi,
I'm using an NgxsDataEntityCollectionsRepository to store multiple entities. Each entities can be grouped by some properties. For example : { currency: 'EUR', group: 'Program1', receivedAmount: 20
}, { currency: 'USD', group: 'Program1', receivedAmount: 5
}, { currency: 'EUR', group: 'Program2', receivedAmount: 15
} Can I simply get sum-ed receivedAmount for group 'Program1' for example ?
I was thinking of using @Computed, maybe I'm wrong ?
Thanks.