From 4517c9100a7ae74e295a62e152c5ba93deefabaa Mon Sep 17 00:00:00 2001 From: Ben PC Date: Thu, 31 Mar 2022 10:34:46 +0200 Subject: [PATCH] Conside Category Name in Searchbar --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 71040ad..d14eef8 100644 --- a/index.js +++ b/index.js @@ -264,7 +264,7 @@ app.get("/search/:query/",authNoRedirectHandler,(req, res) => { } } - mysql_handler.con.query("SELECT *, (SELECT url FROM product_images i WHERE i.product_id = p.id LIMIT 1) as img, (SELECT AVG(rating) FROM reviews r WHERE r.productId = p.id) as rating FROM products p WHERE name LIKE ? "+catQuery+" "+brandQuery+" "+sortQuery+";",["%"+query+"%"],function(err, result){ + mysql_handler.con.query("SELECT *, (SELECT url FROM product_images i WHERE i.product_id = p.id LIMIT 1) as img, (SELECT AVG(rating) FROM reviews r WHERE r.productId = p.id) as rating FROM products p WHERE p.name LIKE ? OR p.id IN (SELECT pc.product_id FROM categories c, product_categories pc WHERE c.id = pc.category_id AND c.name LIKE ?) "+catQuery+" "+brandQuery+" "+sortQuery+";",["%"+query+"%","%"+query+"%"],function(err, result){ if(err) throw err; dict.products = JSON.parse(JSON.stringify(result));