diff --git a/.gitignore b/.gitignore index 9b31034..c303fe9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -.env \ No newline at end of file +.env +tmp \ No newline at end of file diff --git a/controllers/categoryController.js b/controllers/categoryController.js index c0c57e7..4e64d7c 100644 --- a/controllers/categoryController.js +++ b/controllers/categoryController.js @@ -114,14 +114,13 @@ export const updateCategory = async (req, res) => { }; } if (req.files.category_banner) { - if (categ.category_banner) { + if (categ.category_banner.public_id) { const imageId = categ.category_banner.public_id; - // console.log(imageId) + //delete image from claudinary await cloudinary.uploader.destroy(imageId) } - // await cloudinary.uploader.destroy(imageId, function (result) { console.log(result) }); const files = req.files.category_banner; const BannerImage = await cloudinary.uploader.upload(files.tempFilePath, { folder: "image", @@ -138,6 +137,7 @@ export const updateCategory = async (req, res) => { } // console.log(newCategoryData) + //req.user.id, const ModifyCategory = await Category.findByIdAndUpdate(req.params.id, newCategoryData, diff --git a/models/categoryModel.js b/models/categoryModel.js index 556dd88..5f95360 100644 --- a/models/categoryModel.js +++ b/models/categoryModel.js @@ -20,11 +20,11 @@ const categorySchema = new mongoose.Schema( { public_id: { type: String, - required: true, + // required: true, }, url: { type: String, - required: true, + // required: true, }, }, addedOn: {