mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
fix: add count property to item categories list response.
This commit is contained in:
@@ -269,6 +269,9 @@ export default class ItemCategoriesService implements IItemCategoriesService {
|
|||||||
const dynamicList = await this.dynamicListService.dynamicList(tenantId, ItemCategory, filter);
|
const dynamicList = await this.dynamicListService.dynamicList(tenantId, ItemCategory, filter);
|
||||||
|
|
||||||
const itemCategories = await ItemCategory.query().onBuild((query) => {
|
const itemCategories = await ItemCategory.query().onBuild((query) => {
|
||||||
|
// Subquery to calculate sumation of assocaited items to the item category.
|
||||||
|
query.select('*', ItemCategory.relatedQuery('items').count().as('count'));
|
||||||
|
|
||||||
dynamicList.buildQuery()(query);
|
dynamicList.buildQuery()(query);
|
||||||
});
|
});
|
||||||
return { itemCategories, filterMeta: dynamicList.getResponseMeta() };
|
return { itemCategories, filterMeta: dynamicList.getResponseMeta() };
|
||||||
|
|||||||
Reference in New Issue
Block a user