Fixed small bugs
This commit is contained in:
@@ -55,6 +55,13 @@ export class ProductAPI extends SQLDataSource {
|
||||
});
|
||||
}
|
||||
|
||||
createProductFromRow(row: any) {
|
||||
row.blacklisting = this.getBlacklisting(row);
|
||||
row.printProducts = this.getPrintProducts(row);
|
||||
row.designerId = row.designerid;
|
||||
return row;
|
||||
}
|
||||
|
||||
async getProducts(
|
||||
limit: Maybe<number>,
|
||||
visible: Maybe<boolean>,
|
||||
@@ -63,28 +70,17 @@ export class ProductAPI extends SQLDataSource {
|
||||
limit = limit ?? 100;
|
||||
const query = sql.products(limit, visible, browsable);
|
||||
|
||||
return await this.knex.raw(query).then((data) =>
|
||||
data.rows.map((row) => {
|
||||
row.blacklisting = this.getBlacklisting(row);
|
||||
row.printProducts = this.getPrintProducts(row);
|
||||
row.designerId = row.designerid;
|
||||
return row;
|
||||
}),
|
||||
);
|
||||
return await this.knex
|
||||
.raw(query)
|
||||
.then((data) => data.rows.map((row) => this.createProductFromRow(row)));
|
||||
}
|
||||
|
||||
async getProduct(id: number): Promise<Maybe<Product>> {
|
||||
const query = sql.product(id);
|
||||
|
||||
const res = await this.knex.raw(query).then((data) =>
|
||||
data.rows.map((row) => {
|
||||
console.log(row);
|
||||
row.blacklisting = this.getBlacklisting(row);
|
||||
row.printProducts = this.getPrintProducts(row);
|
||||
row.designerId = row.designerid;
|
||||
return row;
|
||||
}),
|
||||
);
|
||||
const res = await this.knex
|
||||
.raw(query)
|
||||
.then((data) => data.rows.map((row) => this.createProductFromRow(row)));
|
||||
return res.find(Boolean);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user