ADD: delete a category by id logic function

This commit is contained in:
MohammadHMazarei
2024-12-29 20:20:10 +03:30
parent 56e18ab402
commit bf653737b7
+10
View File
@@ -29,3 +29,13 @@ module.exports.updateCategory = async (categoryId, data) => {
return category return category
} }
module.exports.deleteCategory = async (categoryId) => {
const category = await Category.findByIdAndDelete(categoryId)
if (!category) {
throw new AppError('NoCategoryFound', 404, {})
}
return null
}