//src/app/modules/academicDepartment/academicDepartment.model.tsacademicDepartmentSchema.pre('save',asyncfunction (next){constisDepartmentExist=awaitAcademicDepartment.findOne({name:this.name,});if (isDepartmentExist){thrownewAppError(httpStatus.NOT_FOUND,'This department is already exist!',);}next();});academicDepartmentSchema.pre('findOneAndUpdate',asyncfunction (next){constquery=this.getQuery();constisDepartmentExist=awaitAcademicDepartment.findOne(query);if (!isDepartmentExist){thrownewAppError(httpStatus.NOT_FOUND,'This department does not exist! ',);}next();});
Top comments (0)
Subscribe
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)