From 50f6e48219458de98658ee42f20ea4bd497d93a4 Mon Sep 17 00:00:00 2001 From: patrickjieraldjuan Date: Sat, 3 Feb 2024 01:12:04 +0800 Subject: [PATCH] added filter to searchProducts controller isActive --- controllers/productControllers.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/controllers/productControllers.js b/controllers/productControllers.js index 041c4ee..36bc930 100644 --- a/controllers/productControllers.js +++ b/controllers/productControllers.js @@ -106,7 +106,10 @@ exports.searchProducts = async (req, res) => { try { const { productName } = req.body; - const products = await Product.find({ name: { $regex: new RegExp(productName, 'i') } }); + const products = await Product.find({ + name: { $regex: new RegExp(productName, 'i') }, + isActive: true + }); res.json({products}); } catch (error) {