From 8c23775362b27a63da0f2b455720d8de15d093e8 Mon Sep 17 00:00:00 2001 From: Sibunnayak Date: Fri, 7 Feb 2025 12:50:03 +0530 Subject: [PATCH] image for orders --- resources/Brands/BrandsController.js | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/resources/Brands/BrandsController.js b/resources/Brands/BrandsController.js index 52e8651..f2abc37 100644 --- a/resources/Brands/BrandsController.js +++ b/resources/Brands/BrandsController.js @@ -289,24 +289,24 @@ export const deleteImageFromCloudinary = async (req, res) => { const response = { result: "ok" }; // Mock response for testing if (response.result === "ok") { // Step 2: Find the brand containing the image and update the database - // const brand = await BrandModel.findOne({ - // "image.public_id": decodedPublicId, - // }); + const brand = await BrandModel.findOne({ + "image.public_id": decodedPublicId, + }); - // if (!brand) { - // return res.status(404).json({ - // success: false, - // msg: "Brand not found with the given image!", - // }); - // } + if (!brand) { + return res.status(404).json({ + success: false, + msg: "Brand not found with the given image!", + }); + } - // // Remove the image from the brand's image array - // brand.image = brand.image.filter( - // (img) => img.public_id !== decodedPublicId - // ); + // Remove the image from the brand's image array + brand.image = brand.image.filter( + (img) => img.public_id !== decodedPublicId + ); - // // Step 3: Save the updated brand document - // await brand.save(); + // Step 3: Save the updated brand document + await brand.save(); return res.status(200).json({ success: true,