image for orders

This commit is contained in:
Sibunnayak 2025-02-07 12:50:03 +05:30
parent bd1a54be8f
commit 8c23775362

View File

@ -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,