// Calculus in service classes:classItemService{getAllAndSumary(){constitems=this.itemRepo.all()constsubItems=this.subItemsRepo.allBy({parentId:In(items.map(d=>d.id))})returnitems.map(d=>({...d,count:this.countSubItemsBy(subItems.filter(sub=>sub.parentId==d.id)),total:this.sumSubItemsBy(subItems.filter(sub=>sub.parentId==d.id))}))}countSubItemsBy(subItems:SubItem[]){// logic }sumSubItemsBy(subItems:SubItem[]){// logic }}
Top comments (0)