//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();});
Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.
Top comments (0)