Skip to content

Commit 574f356

Browse files
[added] serviced for student past history and converted from snake case to camel case
1 parent d7293d1 commit 574f356

File tree

2 files changed

+221
-134
lines changed

2 files changed

+221
-134
lines changed

models/student/stdEduHistory.js

Lines changed: 133 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
11
import connector from "#models/databaseUtil";
22

33
const studentEducationSchema = {
4-
uid: { type: String, require: true },
4+
uid: { type: String, required: true },
55
// tenth_details
66
tenth: {
77
marks: { type: String, required: true },
88
percentage: { type: Number, required: true },
9-
seat_number: { type: String, required: true },
10-
exam_name: { type: String, required: true },
11-
exam_board: { type: String, required: true },
12-
ms_oms: { type: String, required: true },
13-
merit_number_in_qualifying_exam: { type: String, required: true },
14-
admitted_number: { type: String, 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 },
1515
},
16-
cet_hsc_details: {
17-
cet_roll_no: { type: String, required: true },
18-
cet_marks: { type: String, required: true },
19-
qualifying_exam_for_admission: { type: String, required: true },
20-
std_type: { type: String, required: true },
21-
stream_opted: { type: String, required: true },
22-
medium_of_instruction: { type: String, required: true },
23-
agg_total_marks: { type: Number, required: true },
24-
total_marks_out_of: { type: Number, required: true },
25-
percent_of_marks: { type: String, required: true },
26-
attempt_no: { type: String, required: true },
27-
passing_month: { type: String, required: true },
28-
passing_year: { type: String, required: true },
29-
institution_name: { type: String, required: true },
30-
educ_board_name: { type: String, required: true },
31-
pcm_percent: { type: String, required: true },
32-
pbm_percent: { type: String, required: true },
33-
stu_qualifying_exam: { type: String, required: true },
34-
marks_obtained: { type: String, required: true },
35-
state_rank: { type: String, required: true },
36-
prev_exam_seat_number: { type: String, required: false },
37-
prev_tc_number: { type: String, required: false },
38-
hsc_passed_school_name: { type: String, required: true },
39-
board_pattern: { type: String, required: true },
40-
scholarship_name: { type: String, required: false },
41-
scholarship_type: { type: String, required: false },
42-
dte_seat_type: { type: String, required: true },
43-
dte_user_password: { type: String, required: true },
44-
dte_user_id: { type: String, required: true },
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 },
4545
},
46-
graduation_details: {
47-
graduation_institute: { type: String, required: true },
48-
graduation_branch: { type: String, required: true },
49-
graduation_degree: { type: String, required: true },
50-
graduation_marks_pct: { type: Number, required: true },
51-
graduations_passing_year: { type: String, required: true },
52-
urban_rural: { type: String, required: true },
53-
scholarship_number: { type: String, required: false },
54-
last_school_college_attended: { type: String, required: true },
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 },
5555
},
5656
};
5757

@@ -63,52 +63,52 @@ async function create(studentEducationData) {
6363
tenth: {
6464
marks,
6565
percentage,
66-
seat_number,
67-
exam_name,
68-
exam_board,
69-
ms_oms,
70-
merit_number_in_qualifying_exam,
71-
admitted_number,
66+
seatNumber,
67+
examName,
68+
examBoard,
69+
msOms,
70+
meritNumberInQualifyingExam,
71+
admittedNumber,
7272
},
73-
cet_hsc_details: {
74-
cet_roll_no,
75-
cet_marks,
76-
qualifying_exam_for_admission,
77-
std_type,
78-
stream_opted,
79-
medium_of_instruction,
80-
agg_total_marks,
81-
total_marks_out_of,
82-
percent_of_marks,
83-
attempt_no,
84-
passing_month,
85-
passing_year,
86-
institution_name,
87-
educ_board_name,
88-
pcm_percent,
89-
pbm_percent,
90-
stu_qualifying_exam,
91-
marks_obtained,
92-
state_rank,
93-
prev_exam_seat_number,
94-
prev_tc_number,
95-
hsc_passed_school_name,
96-
board_pattern,
97-
scholarship_name,
98-
scholarship_type,
99-
dte_seat_type,
100-
dte_user_password,
101-
dte_user_id,
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,
102102
},
103-
graduation_details: {
104-
graduation_institute,
105-
graduation_branch,
106-
graduation_degree,
107-
graduation_marks_pct,
108-
graduations_passing_year,
109-
urban_rural,
110-
scholarship_number,
111-
last_school_college_attended,
103+
graduationDetails: {
104+
graduationInstitute,
105+
graduationBranch,
106+
graduationDegree,
107+
graduationMarksPct,
108+
graduationsPassingYear,
109+
urbanRural,
110+
scholarshipNumber,
111+
lastSchoolCollegeAttended,
112112
},
113113
} = studentEducationData;
114114

@@ -117,60 +117,59 @@ async function create(studentEducationData) {
117117
tenth: {
118118
marks,
119119
percentage,
120-
seat_number,
121-
exam_name,
122-
exam_board,
123-
ms_oms,
124-
merit_number_in_qualifying_exam,
125-
admitted_number,
120+
seatNumber,
121+
examName,
122+
examBoard,
123+
msOms,
124+
meritNumberInQualifyingExam,
125+
admittedNumber,
126126
},
127-
cet_hsc_details: {
128-
cet_roll_no,
129-
cet_marks,
130-
qualifying_exam_for_admission,
131-
std_type,
132-
stream_opted,
133-
medium_of_instruction,
134-
agg_total_marks,
135-
total_marks_out_of,
136-
percent_of_marks,
137-
attempt_no,
138-
passing_month,
139-
passing_year,
140-
institution_name,
141-
educ_board_name,
142-
pcm_percent,
143-
pbm_percent,
144-
stu_qualifying_exam,
145-
marks_obtained,
146-
state_rank,
147-
prev_exam_seat_number,
148-
prev_tc_number,
149-
hsc_passed_school_name,
150-
board_pattern,
151-
scholarship_name,
152-
scholarship_type,
153-
dte_seat_type,
154-
dte_user_password,
155-
dte_user_id,
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,
156156
},
157-
graduation_details: {
158-
graduation_institute,
159-
graduation_branch,
160-
graduation_degree,
161-
graduation_marks_pct,
162-
graduations_passing_year,
163-
urban_rural,
164-
scholarship_number,
165-
last_school_college_attended,
157+
graduationDetails: {
158+
graduationInstitute,
159+
graduationBranch,
160+
graduationDegree,
161+
graduationMarksPct,
162+
graduationsPassingYear,
163+
urbanRural,
164+
scholarshipNumber,
165+
lastSchoolCollegeAttended,
166166
},
167167
});
168168
const stdEducationDoc = await stdEducation.save();
169169
return stdEducationDoc;
170170

171171
}
172172

173-
174173
async function read(filter, limit = 1) {
175174
const stdEducationDoc = studentEducationSchema.find(filter).limit(limit);
176175
return stdEducationDoc

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)