fix products
This commit is contained in:
@@ -52,8 +52,13 @@ router.get('/', async (req, res, next) => {
|
|||||||
|
|
||||||
if (search) {
|
if (search) {
|
||||||
paramCount++;
|
paramCount++;
|
||||||
whereConditions.push(`(p.name ILIKE $${paramCount} OR p.brand ILIKE $${paramCount} OR p.active_ingredients ILIKE $${paramCount})`);
|
const searchParam1 = paramCount;
|
||||||
queryParams.push(`%${search}%`);
|
paramCount++;
|
||||||
|
const searchParam2 = paramCount;
|
||||||
|
paramCount++;
|
||||||
|
const searchParam3 = paramCount;
|
||||||
|
whereConditions.push(`(p.name ILIKE $${searchParam1} OR p.brand ILIKE $${searchParam2} OR p.active_ingredients ILIKE $${searchParam3})`);
|
||||||
|
queryParams.push(`%${search}%`, `%${search}%`, `%${search}%`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const whereClause = whereConditions.length > 0 ? `AND ${whereConditions.join(' AND ')}` : '';
|
const whereClause = whereConditions.length > 0 ? `AND ${whereConditions.join(' AND ')}` : '';
|
||||||
|
|||||||
Reference in New Issue
Block a user