image for orders
This commit is contained in:
parent
bd1a54be8f
commit
8c23775362
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user