From fdd136ac4076e578f2a6ba8cf0bf38d23c798090 Mon Sep 17 00:00:00 2001 From: MohammadHMazarei Date: Wed, 25 Dec 2024 19:43:24 +0330 Subject: [PATCH] FIX: createRole, updateRole, and deleteRole logics --- components/role/roleService.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/role/roleService.js b/components/role/roleService.js index 917db0b..8b6ab87 100644 --- a/components/role/roleService.js +++ b/components/role/roleService.js @@ -6,7 +6,7 @@ module.exports.getAllRoles = async () => { } module.exports.createRole = async (data) => { - return Role.create(data, null) + return await Role.create(data) } module.exports.getRole = async (roleId) => { @@ -20,7 +20,7 @@ module.exports.getRole = async (roleId) => { } module.exports.updateRole = async (roleId, data) => { - const role = await Role.findOneAndUpdate({ _id: roleId},data, null) + const role = await Role.findOneAndUpdate({ _id: roleId }, data, { new: true }) if (!role) { throw new AppError('NoRoleFound', 404, {}) @@ -30,7 +30,7 @@ module.exports.updateRole = async (roleId, data) => { } module.exports.deleteRole = async (roleId) => { - const role = await Role.findByIdAndUpdate(roleId, { isActive: false }, null) + const role = await Role.findByIdAndUpdate(roleId, { isActive: false }, { new: true }) if (!role) { throw new AppError('NoRoleFound', 404, {})