|
| 1 | +import connector from "#models/databaseUtil"; |
| 2 | + |
| 3 | +const studentEducationSchema = { |
| 4 | + uid: { type: String, required: true }, |
| 5 | + // tenth_details |
| 6 | + tenth: { |
| 7 | + marks: { type: String, required: true }, |
| 8 | + percentage: { type: Number, required: true }, |
| 9 | + seatNumber: { type: String, required: true }, |
| 10 | + examName: { type: String, required: true }, |
| 11 | + examBoard: { type: String, required: true }, |
| 12 | + msOms: { type: String, required: true }, |
| 13 | + meritNumberInQualifyingExam: { type: String, required: true }, |
| 14 | + admittedNumber: { type: String, required: true }, |
| 15 | + }, |
| 16 | + cetHscDetails: { |
| 17 | + cetRollNo: { type: String, required: true }, |
| 18 | + cetMarks: { type: String, required: true }, |
| 19 | + qualifyingExamForAdmission: { type: String, required: true }, |
| 20 | + stdType: { type: String, required: true }, |
| 21 | + streamOpted: { type: String, required: true }, |
| 22 | + mediumOfInstruction: { type: String, required: true }, |
| 23 | + aggTotalMarks: { type: Number, required: true }, |
| 24 | + totalMarksOutOf: { type: Number, required: true }, |
| 25 | + percentOfMarks: { type: String, required: true }, |
| 26 | + attemptNo: { type: String, required: true }, |
| 27 | + passingMonth: { type: String, required: true }, |
| 28 | + passingYear: { type: String, required: true }, |
| 29 | + institutionName: { type: String, required: true }, |
| 30 | + educBoardName: { type: String, required: true }, |
| 31 | + pcmPercent: { type: String, required: true }, |
| 32 | + pbmPercent: { type: String, required: true }, |
| 33 | + stuQualifyingExam: { type: String, required: true }, |
| 34 | + marksObtained: { type: String, required: true }, |
| 35 | + stateRank: { type: String, required: true }, |
| 36 | + prevExamSeatNumber: { type: String, required: false }, |
| 37 | + prevTcNumber: { type: String, required: false }, |
| 38 | + hscPassedSchoolName: { type: String, required: true }, |
| 39 | + boardPattern: { type: String, required: true }, |
| 40 | + scholarshipName: { type: String, required: false }, |
| 41 | + scholarshipType: { type: String, required: false }, |
| 42 | + dteSeatType: { type: String, required: true }, |
| 43 | + dteUserPassword: { type: String, required: true }, |
| 44 | + dteUserId: { type: String, required: true }, |
| 45 | + }, |
| 46 | + graduationDetails: { |
| 47 | + graduationInstitute: { type: String, required: true }, |
| 48 | + graduationBranch: { type: String, required: true }, |
| 49 | + graduationDegree: { type: String, required: true }, |
| 50 | + graduationMarksPct: { type: Number, required: true }, |
| 51 | + graduationsPassingYear: { type: String, required: true }, |
| 52 | + urbanRural: { type: String, required: true }, |
| 53 | + scholarshipNumber: { type: String, required: false }, |
| 54 | + lastSchoolCollegeAttended: { type: String, required: true }, |
| 55 | + }, |
| 56 | +}; |
| 57 | + |
| 58 | +const StudentEducation = connector.model("Student education", studentEducationSchema); |
| 59 | + |
| 60 | +async function create(studentEducationData) { |
| 61 | + const { |
| 62 | + uid, |
| 63 | + tenth: { |
| 64 | + marks, |
| 65 | + percentage, |
| 66 | + seatNumber, |
| 67 | + examName, |
| 68 | + examBoard, |
| 69 | + msOms, |
| 70 | + meritNumberInQualifyingExam, |
| 71 | + admittedNumber, |
| 72 | + }, |
| 73 | + cetHscDetails: { |
| 74 | + cetRollNo, |
| 75 | + cetMarks, |
| 76 | + qualifyingExamForAdmission, |
| 77 | + stdType, |
| 78 | + streamOpted, |
| 79 | + mediumOfInstruction, |
| 80 | + aggTotalMarks, |
| 81 | + totalMarksOutOf, |
| 82 | + percentOfMarks, |
| 83 | + attemptNo, |
| 84 | + passingMonth, |
| 85 | + passingYear, |
| 86 | + institutionName, |
| 87 | + educBoardName, |
| 88 | + pcmPercent, |
| 89 | + pbmPercent, |
| 90 | + stuQualifyingExam, |
| 91 | + marksObtained, |
| 92 | + stateRank, |
| 93 | + prevExamSeatNumber, |
| 94 | + prevTcNumber, |
| 95 | + hscPassedSchoolName, |
| 96 | + boardPattern, |
| 97 | + scholarshipName, |
| 98 | + scholarshipType, |
| 99 | + dteSeatType, |
| 100 | + dteUserPassword, |
| 101 | + dteUserId, |
| 102 | + }, |
| 103 | + graduationDetails: { |
| 104 | + graduationInstitute, |
| 105 | + graduationBranch, |
| 106 | + graduationDegree, |
| 107 | + graduationMarksPct, |
| 108 | + graduationsPassingYear, |
| 109 | + urbanRural, |
| 110 | + scholarshipNumber, |
| 111 | + lastSchoolCollegeAttended, |
| 112 | + }, |
| 113 | + } = studentEducationData; |
| 114 | + |
| 115 | + const stdEducation = new StudentEducation({ |
| 116 | + uid, |
| 117 | + tenth: { |
| 118 | + marks, |
| 119 | + percentage, |
| 120 | + seatNumber, |
| 121 | + examName, |
| 122 | + examBoard, |
| 123 | + msOms, |
| 124 | + meritNumberInQualifyingExam, |
| 125 | + admittedNumber, |
| 126 | + }, |
| 127 | + cetHscDetails: { |
| 128 | + cetRollNo, |
| 129 | + cetMarks, |
| 130 | + qualifyingExamForAdmission, |
| 131 | + stdType, |
| 132 | + streamOpted, |
| 133 | + mediumOfInstruction, |
| 134 | + aggTotalMarks, |
| 135 | + totalMarksOutOf, |
| 136 | + percentOfMarks, |
| 137 | + attemptNo, |
| 138 | + passingMonth, |
| 139 | + passingYear, |
| 140 | + institutionName, |
| 141 | + educBoardName, |
| 142 | + pcmPercent, |
| 143 | + pbmPercent, |
| 144 | + stuQualifyingExam, |
| 145 | + marksObtained, |
| 146 | + stateRank, |
| 147 | + prevExamSeatNumber, |
| 148 | + prevTcNumber, |
| 149 | + hscPassedSchoolName, |
| 150 | + boardPattern, |
| 151 | + scholarshipName, |
| 152 | + scholarshipType, |
| 153 | + dteSeatType, |
| 154 | + dteUserPassword, |
| 155 | + dteUserId, |
| 156 | + }, |
| 157 | + graduationDetails: { |
| 158 | + graduationInstitute, |
| 159 | + graduationBranch, |
| 160 | + graduationDegree, |
| 161 | + graduationMarksPct, |
| 162 | + graduationsPassingYear, |
| 163 | + urbanRural, |
| 164 | + scholarshipNumber, |
| 165 | + lastSchoolCollegeAttended, |
| 166 | + }, |
| 167 | + }); |
| 168 | + const stdEducationDoc = await stdEducation.save(); |
| 169 | + return stdEducationDoc; |
| 170 | + |
| 171 | +} |
| 172 | + |
| 173 | +async function read(filter, limit = 1) { |
| 174 | + const stdEducationDoc = studentEducationSchema.find(filter).limit(limit); |
| 175 | + return stdEducationDoc; |
| 176 | +} |
| 177 | + |
| 178 | +async function update(filter, updateObject, options = { multi: true }) { |
| 179 | + const updateResult = await studentEducationSchema.updateMany( |
| 180 | + filter, |
| 181 | + { $set: updateObject }, |
| 182 | + options, |
| 183 | + ); |
| 184 | + return updateResult.acknowledged; |
| 185 | +} |
| 186 | + |
| 187 | +async function remove(stdEducationId) { |
| 188 | + const deleteResult = await studentEducationSchema.deleteMany(stdEducationId); |
| 189 | + return deleteResult.acknowledged; |
| 190 | +} |
| 191 | + |
| 192 | +export default { |
| 193 | + create, |
| 194 | + read, |
| 195 | + update, |
| 196 | + remove, |
| 197 | +}; |
0 commit comments