fix products

This commit is contained in:
Jake Kasper
2025-08-28 14:12:23 -04:00
parent 2ea40e1bdd
commit fefbc4f053

View File

@@ -52,8 +52,13 @@ router.get('/', async (req, res, next) => {
if (search) {
paramCount++;
whereConditions.push(`(p.name ILIKE $${paramCount} OR p.brand ILIKE $${paramCount} OR p.active_ingredients ILIKE $${paramCount})`);
queryParams.push(`%${search}%`);
const searchParam1 = paramCount;
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 ')}` : '';