add category banner image

This commit is contained in:
pawan-dot 2022-10-27 13:43:31 +05:30
parent 109c213e9c
commit b61436183b
3 changed files with 7 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules
.env
tmp

View File

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

View File

@ -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: {