Add search for products in all sub categories (#68)
This commit is contained in:
@@ -88,8 +88,8 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
return mem;
|
||||
}, {});
|
||||
|
||||
fields['artNo'] = fields['artNo'];
|
||||
fields['name'] = fields['name'];
|
||||
fields['artNo'] = fields['artNo'] ?? ''; // some actually exists without artNo
|
||||
fields['name'] = fields['name'] ?? ''; // some actually exists without name
|
||||
fields['copyright'] = fields['copyright'] ?? '';
|
||||
fields['comments'] = fields['comments'] ?? '';
|
||||
fields['batch'] = fields['batch'] ?? '';
|
||||
@@ -196,6 +196,16 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
.then((data) => data.rows.map((row) => this.createProductFromRow(row)));
|
||||
}
|
||||
|
||||
async getCategoryWithSubCategoriesProducts(
|
||||
categoryId: number,
|
||||
): Promise<Array<Product>> {
|
||||
const query = sql.categoryWithAllSubCategoriesProducts(categoryId);
|
||||
|
||||
return this.knex
|
||||
.raw(query)
|
||||
.then((data) => data.rows.map((row) => this.createProductFromRow(row)));
|
||||
}
|
||||
|
||||
async getKeywordProducts(keywordId: number): Promise<Array<Product>> {
|
||||
const query = sql.keywordProducts(keywordId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user