ADD: update a category by id logic
This commit is contained in:
@@ -19,3 +19,13 @@ module.exports.getCategory = async (categoryId) => {
|
|||||||
|
|
||||||
return category
|
return category
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.updateCategory = async (categoryId, data) => {
|
||||||
|
const category = await Category.findOneAndUpdate({ _id: categoryId }, data, { new: true })
|
||||||
|
|
||||||
|
if (!category) {
|
||||||
|
throw new AppError('NoCategoryFound', 404, {})
|
||||||
|
}
|
||||||
|
|
||||||
|
return category
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user