Skip to content

Commit a230e89

Browse files
authored
Merge pull request #463 from tcet-opensource/461-feat-added-transactions-while-creating-students-details
200-Addressed-461-Use-of-Session-and-Transaction-to-maintain-acid-edi…
2 parents 87924bc + e91ec5b commit a230e89

File tree

9 files changed

+1252
-209
lines changed

9 files changed

+1252
-209
lines changed

controller/student.js

Lines changed: 381 additions & 14 deletions
Large diffs are not rendered by default.

models/student.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async function create(studentData) {
3939
rollNo,
4040
coursesOpted,
4141
});
42-
const studentDoc = await student.save();
42+
const studentDoc = await student.save({ session: studentData.session });
4343
return studentDoc;
4444
}
4545

models/student/stdBank.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async function create(studentBankData) {
4949
bankMicr,
5050
});
5151

52-
const stdBankDoc = await stdBank.save();
52+
const stdBankDoc = await stdBank.save({ session: studentBankData.session });
5353
return stdBankDoc;
5454
}
5555

models/student/stdCollege.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ async function create(studentCollegeData) {
9393
enrollmentNo,
9494
});
9595

96-
const stdCollegeDoc = await stdCollege.save();
96+
const stdCollegeDoc = await stdCollege.save({
97+
session: studentCollegeData.session,
98+
});
9799
return stdCollegeDoc;
98100
}
99101

models/student/stdEduHistory.js

Lines changed: 152 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,56 @@ import connector from "#models/databaseUtil";
33
const studentEducationSchema = {
44
uid: { type: String, required: true },
55
// 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-
},
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+
// },
5656
};
5757

5858
const StudentEducation = connector.model(
@@ -63,110 +63,110 @@ const StudentEducation = connector.model(
6363
async function create(studentEducationData) {
6464
const {
6565
uid,
66-
tenth: {
67-
marks,
68-
percentage,
69-
seatNumber,
70-
examName,
71-
examBoard,
72-
msOms,
73-
meritNumberInQualifyingExam,
74-
admittedNumber,
75-
},
76-
cetHscDetails: {
77-
cetRollNo,
78-
cetMarks,
79-
qualifyingExamForAdmission,
80-
stdType,
81-
streamOpted,
82-
mediumOfInstruction,
83-
aggTotalMarks,
84-
totalMarksOutOf,
85-
percentOfMarks,
86-
attemptNo,
87-
passingMonth,
88-
passingYear,
89-
institutionName,
90-
educBoardName,
91-
pcmPercent,
92-
pbmPercent,
93-
stuQualifyingExam,
94-
marksObtained,
95-
stateRank,
96-
prevExamSeatNumber,
97-
prevTcNumber,
98-
hscPassedSchoolName,
99-
boardPattern,
100-
scholarshipName,
101-
scholarshipType,
102-
dteSeatType,
103-
dteUserPassword,
104-
dteUserId,
105-
},
106-
graduationDetails: {
107-
graduationInstitute,
108-
graduationBranch,
109-
graduationDegree,
110-
graduationMarksPct,
111-
graduationsPassingYear,
112-
urbanRural,
113-
scholarshipNumber,
114-
lastSchoolCollegeAttended,
115-
},
66+
// tenth: {
67+
marks,
68+
percentage,
69+
seatNumber,
70+
examName,
71+
examBoard,
72+
msOms,
73+
meritNumberInQualifyingExam,
74+
admittedNumber,
75+
// },
76+
// cetHscDetails: {
77+
cetRollNo,
78+
cetMarks,
79+
qualifyingExamForAdmission,
80+
stdType,
81+
streamOpted,
82+
mediumOfInstruction,
83+
aggTotalMarks,
84+
totalMarksOutOf,
85+
percentOfMarks,
86+
attemptNo,
87+
passingMonth,
88+
passingYear,
89+
institutionName,
90+
educBoardName,
91+
pcmPercent,
92+
pbmPercent,
93+
stuQualifyingExam,
94+
marksObtained,
95+
stateRank,
96+
prevExamSeatNumber,
97+
prevTcNumber,
98+
hscPassedSchoolName,
99+
boardPattern,
100+
scholarshipName,
101+
scholarshipType,
102+
dteSeatType,
103+
dteUserPassword,
104+
dteUserId,
105+
// },
106+
// graduationDetails: {
107+
graduationInstitute,
108+
graduationBranch,
109+
graduationDegree,
110+
graduationMarksPct,
111+
graduationsPassingYear,
112+
urbanRural,
113+
scholarshipNumber,
114+
lastSchoolCollegeAttended,
115+
// },
116116
} = studentEducationData;
117117

118118
const stdEducation = new StudentEducation({
119119
uid,
120-
tenth: {
121-
marks,
122-
percentage,
123-
seatNumber,
124-
examName,
125-
examBoard,
126-
msOms,
127-
meritNumberInQualifyingExam,
128-
admittedNumber,
129-
},
130-
cetHscDetails: {
131-
cetRollNo,
132-
cetMarks,
133-
qualifyingExamForAdmission,
134-
stdType,
135-
streamOpted,
136-
mediumOfInstruction,
137-
aggTotalMarks,
138-
totalMarksOutOf,
139-
percentOfMarks,
140-
attemptNo,
141-
passingMonth,
142-
passingYear,
143-
institutionName,
144-
educBoardName,
145-
pcmPercent,
146-
pbmPercent,
147-
stuQualifyingExam,
148-
marksObtained,
149-
stateRank,
150-
prevExamSeatNumber,
151-
prevTcNumber,
152-
hscPassedSchoolName,
153-
boardPattern,
154-
scholarshipName,
155-
scholarshipType,
156-
dteSeatType,
157-
dteUserPassword,
158-
dteUserId,
159-
},
160-
graduationDetails: {
161-
graduationInstitute,
162-
graduationBranch,
163-
graduationDegree,
164-
graduationMarksPct,
165-
graduationsPassingYear,
166-
urbanRural,
167-
scholarshipNumber,
168-
lastSchoolCollegeAttended,
169-
},
120+
// tenth: {
121+
marks,
122+
percentage,
123+
seatNumber,
124+
examName,
125+
examBoard,
126+
msOms,
127+
meritNumberInQualifyingExam,
128+
admittedNumber,
129+
// },
130+
// cetHscDetails: {
131+
cetRollNo,
132+
cetMarks,
133+
qualifyingExamForAdmission,
134+
stdType,
135+
streamOpted,
136+
mediumOfInstruction,
137+
aggTotalMarks,
138+
totalMarksOutOf,
139+
percentOfMarks,
140+
attemptNo,
141+
passingMonth,
142+
passingYear,
143+
institutionName,
144+
educBoardName,
145+
pcmPercent,
146+
pbmPercent,
147+
stuQualifyingExam,
148+
marksObtained,
149+
stateRank,
150+
prevExamSeatNumber,
151+
prevTcNumber,
152+
hscPassedSchoolName,
153+
boardPattern,
154+
scholarshipName,
155+
scholarshipType,
156+
dteSeatType,
157+
dteUserPassword,
158+
dteUserId,
159+
// },
160+
// graduationDetails: {
161+
graduationInstitute,
162+
graduationBranch,
163+
graduationDegree,
164+
graduationMarksPct,
165+
graduationsPassingYear,
166+
urbanRural,
167+
scholarshipNumber,
168+
lastSchoolCollegeAttended,
169+
// },
170170
});
171171
const stdEducationDoc = await stdEducation.save();
172172
return stdEducationDoc;
@@ -183,7 +183,7 @@ async function read(filter, limit = 0, page = 1) {
183183
}
184184

185185
async function update(filter, updateObject, options = { multi: true }) {
186-
const updateResult = await studentEducationSchema.updateMany(
186+
const updateResult = await StudentEducation.updateMany(
187187
filter,
188188
{ $set: updateObject },
189189
options,
@@ -192,7 +192,7 @@ async function update(filter, updateObject, options = { multi: true }) {
192192
}
193193

194194
async function remove(stdEducationId) {
195-
const deleteResult = await studentEducationSchema.deleteMany(stdEducationId);
195+
const deleteResult = await StudentEducation.deleteMany(stdEducationId);
196196
return deleteResult.acknowledged;
197197
}
198198

models/student/stdMedHistory.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ async function create(studentMedicalData) {
4141
parentsContact,
4242
relativeContacts,
4343
});
44-
const medicalHistoryDoc = await medicalHistory.save();
44+
const medicalHistoryDoc = await medicalHistory.save({
45+
session: studentMedicalData.session,
46+
});
4547
return medicalHistoryDoc;
4648
}
4749

models/student/stdPersonal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ async function create(studentData) {
248248
thumbUploaded,
249249
noOfDocumentsUploaded,
250250
});
251-
const studentDoc = await student.save();
251+
const studentDoc = await student.save({ session: studentData.session });
252252
return studentDoc;
253253
}
254254

0 commit comments

Comments
 (0)