Skip to content

Commit 97f2e45

Browse files
Merge pull request #389 from tcet-opensource/370-CRUD-and-Services-for-Student-Past-Education-details
370 crud and services for student past education details
2 parents a238c17 + 23eccb2 commit 97f2e45

File tree

3 files changed

+285
-59
lines changed

3 files changed

+285
-59
lines changed

models/student/stdEduHistory.js

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
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+
};

models/student/std_edu_history.js

Lines changed: 0 additions & 59 deletions
This file was deleted.

services/student/stdEduHistory.js

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import StudentEducation from "#models/student/stdEduHistory";
2+
import databaseError from "#error/database";
3+
4+
export async function createStudentEducation(
5+
uid,
6+
tenth,
7+
cetHscDetails,
8+
graduationDetails,
9+
) {
10+
const newStudentEducation = await StudentEducation.create({
11+
uid,
12+
tenth: {
13+
marks: tenth.marks,
14+
percentage: tenth.percentage,
15+
seatNumber: tenth.seatNumber,
16+
examName: tenth.examName,
17+
examBoard: tenth.examBoard,
18+
msOms: tenth.msOms,
19+
meritNumberInQualifyingExam: tenth.meritNumberInQualifyingExam,
20+
admittedNumber: tenth.admittedNumber,
21+
},
22+
cetHscDetails: {
23+
cetRollNo: cetHscDetails.cetRollNo,
24+
cetMarks: cetHscDetails.cetMarks,
25+
qualifyingExamForAdmission: cetHscDetails.qualifyingExamForAdmission,
26+
stdType: cetHscDetails.stdType,
27+
streamOpted: cetHscDetails.streamOpted,
28+
mediumOfInstruction: cetHscDetails.mediumOfInstruction,
29+
aggTotalMarks: cetHscDetails.aggTotalMarks,
30+
totalMarksOutOf: cetHscDetails.totalMarksOutOf,
31+
percentOfMarks: cetHscDetails.percentOfMarks,
32+
attemptNo: cetHscDetails.attemptNo,
33+
passingMonth: cetHscDetails.passingMonth,
34+
passingYear: cetHscDetails.passingYear,
35+
institutionName: cetHscDetails.institutionName,
36+
educBoardName: cetHscDetails.educBoardName,
37+
pcmPercent: cetHscDetails.pcmPercent,
38+
pbmPercent: cetHscDetails.pbmPercent,
39+
stuQualifyingExam: cetHscDetails.stuQualifyingExam,
40+
marksObtained: cetHscDetails.marksObtained,
41+
stateRank: cetHscDetails.stateRank,
42+
prevExamSeatNumber: cetHscDetails.prevExamSeatNumber,
43+
prevTcNumber: cetHscDetails.prevTcNumber,
44+
hscPassedSchoolName: cetHscDetails.hscPassedSchoolName,
45+
boardPattern: cetHscDetails.boardPattern,
46+
scholarshipName: cetHscDetails.scholarshipName,
47+
scholarshipType: cetHscDetails.scholarshipType,
48+
dteSeatType: cetHscDetails.dteSeatType,
49+
dteUserPassword: cetHscDetails.dteUserPassword,
50+
dteUserId: cetHscDetails.dteUserId,
51+
},
52+
graduationDetails: {
53+
graduationInstitute: graduationDetails.graduationInstitute,
54+
graduationBranch: graduationDetails.graduationBranch,
55+
graduationDegree: graduationDetails.graduationDegree,
56+
graduationMarksPct: graduationDetails.graduationMarksPct,
57+
graduationsPassingYear: graduationDetails.graduationsPassingYear,
58+
urbanRural: graduationDetails.urbanRural,
59+
scholarshipNumber: graduationDetails.scholarshipNumber,
60+
lastSchoolCollegeAttended: graduationDetails.lastSchoolCollegeAttended,
61+
},
62+
});
63+
if (newStudentEducation.uid === uid) {
64+
return newStudentEducation;
65+
}
66+
throw new databaseError.DataEntryError("student education");
67+
}
68+
69+
export async function updateStudentEducationById(id, data) {
70+
const updated = await StudentEducation.update({ _id: id }, data);
71+
if (updated) {
72+
return updated;
73+
}
74+
throw new databaseError.DataEntryError("student education");
75+
}
76+
77+
export async function studentEducationList(filter) {
78+
const studentEducationDetails = await StudentEducation.read(filter, 0);
79+
return studentEducationDetails;
80+
}
81+
82+
export async function deleteStudentEducationById(studentEducationId) {
83+
const deleted = await StudentEducation.remove({ _id: studentEducationId });
84+
if (deleted) {
85+
return deleted;
86+
}
87+
throw new databaseError.DataDeleteError("student education");
88+
}

0 commit comments

Comments
 (0)