diff --git a/controllers/directoryController.js b/controllers/directoryController.js index 1db90db..23dd507 100644 --- a/controllers/directoryController.js +++ b/controllers/directoryController.js @@ -106,30 +106,14 @@ export const getOneDirectory = async (req, res) => { export const updateDirectory = async (req, res) => { try { - const newDirectoryData = { - ...req.body, - }; - const files = req.files.image; + // const newDirectoryData = { + // name: req.body.name, + // // email: req.body.email, + // }; + // console.log(newCategoryData) + //req.user.id, - if (req.files.image !== "") { - const dir = await directoryModel.findById(req.params.id); - if (dir.image.public_id) { - const imageId = dir.image.public_id; - // console.log(imageId) - //delete image from claudinary - await cloudinary.uploader.destroy(imageId) - - const myCloud = await cloudinary.uploader.upload(files.tempFilePath, { - folder: "image", - }, - function (error, result) { (result, error) }); - newDirectoryData.image = { - public_id: myCloud.public_id, - url: myCloud.secure_url, - }; - } - } - const ModifyDirectory = await directoryModel.findByIdAndUpdate(req.params.id, newDirectoryData, + const ModifyDirectory = await directoryModel.findByIdAndUpdate(req.params.id, req.body, { new: true } // runValidators: true, @@ -142,7 +126,7 @@ export const updateDirectory = async (req, res) => { }); } catch (error) { - // console.log(error) + console.log(error) res.status(500).json({ success: false, msg: "Failled to UpDate !!" diff --git a/tmp/tmp-1-1654839891606 b/tmp/tmp-1-1654839891606 new file mode 100644 index 0000000..ab5ef1b Binary files /dev/null and b/tmp/tmp-1-1654839891606 differ diff --git a/tmp/tmp-1-1654839946267 b/tmp/tmp-1-1654839946267 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1654839946267 differ diff --git a/tmp/tmp-1-1654839995341 b/tmp/tmp-1-1654839995341 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1654839995341 differ diff --git a/tmp/tmp-2-1654839915329 b/tmp/tmp-2-1654839915329 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-2-1654839915329 differ diff --git a/tmp/tmp-2-1654840109983 b/tmp/tmp-2-1654840109983 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-2-1654840109983 differ