Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

200-Addressed-461-Use-of-Session-and-Transaction-to-maintain-acid-edi… #463

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
395 changes: 381 additions & 14 deletions controller/student.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion models/student.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function create(studentData) {
rollNo,
coursesOpted,
});
const studentDoc = await student.save();
const studentDoc = await student.save({ session: studentData.session });
return studentDoc;
}

Expand Down
2 changes: 1 addition & 1 deletion models/student/stdBank.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function create(studentBankData) {
bankMicr,
});

const stdBankDoc = await stdBank.save();
const stdBankDoc = await stdBank.save({ session: studentBankData.session });
return stdBankDoc;
}

Expand Down
4 changes: 3 additions & 1 deletion models/student/stdCollege.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ async function create(studentCollegeData) {
enrollmentNo,
});

const stdCollegeDoc = await stdCollege.save();
const stdCollegeDoc = await stdCollege.save({
session: studentCollegeData.session,
});
return stdCollegeDoc;
}

Expand Down
304 changes: 152 additions & 152 deletions models/student/stdEduHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,56 @@ import connector from "#models/databaseUtil";
const studentEducationSchema = {
uid: { type: String, required: true },
// tenth_details
tenth: {
marks: { type: String, required: true },
percentage: { type: Number, required: true },
seatNumber: { type: String, required: true },
examName: { type: String, required: true },
examBoard: { type: String, required: true },
msOms: { type: String, required: true },
meritNumberInQualifyingExam: { type: String, required: true },
admittedNumber: { type: String, required: true },
},
cetHscDetails: {
cetRollNo: { type: String, required: true },
cetMarks: { type: String, required: true },
qualifyingExamForAdmission: { type: String, required: true },
stdType: { type: String, required: true },
streamOpted: { type: String, required: true },
mediumOfInstruction: { type: String, required: true },
aggTotalMarks: { type: Number, required: true },
totalMarksOutOf: { type: Number, required: true },
percentOfMarks: { type: String, required: true },
attemptNo: { type: String, required: true },
passingMonth: { type: String, required: true },
passingYear: { type: String, required: true },
institutionName: { type: String, required: true },
educBoardName: { type: String, required: true },
pcmPercent: { type: String, required: true },
pbmPercent: { type: String, required: true },
stuQualifyingExam: { type: String, required: true },
marksObtained: { type: String, required: true },
stateRank: { type: String, required: true },
prevExamSeatNumber: { type: String, required: false },
prevTcNumber: { type: String, required: false },
hscPassedSchoolName: { type: String, required: true },
boardPattern: { type: String, required: true },
scholarshipName: { type: String, required: false },
scholarshipType: { type: String, required: false },
dteSeatType: { type: String, required: true },
dteUserPassword: { type: String, required: true },
dteUserId: { type: String, required: true },
},
graduationDetails: {
graduationInstitute: { type: String, required: true },
graduationBranch: { type: String, required: true },
graduationDegree: { type: String, required: true },
graduationMarksPct: { type: Number, required: true },
graduationsPassingYear: { type: String, required: true },
urbanRural: { type: String, required: true },
scholarshipNumber: { type: String, required: false },
lastSchoolCollegeAttended: { type: String, required: true },
},
// tenth: {
marks: { type: String, required: true },
percentage: { type: Number, required: true },
seatNumber: { type: String, required: true },
examName: { type: String, required: true },
examBoard: { type: String, required: true },
msOms: { type: String, required: true },
meritNumberInQualifyingExam: { type: String, required: true },
admittedNumber: { type: String, required: true },
// },
// cetHscDetails: {
cetRollNo: { type: String, required: true },
cetMarks: { type: String, required: true },
qualifyingExamForAdmission: { type: String, required: true },
stdType: { type: String, required: true },
streamOpted: { type: String, required: true },
mediumOfInstruction: { type: String, required: true },
aggTotalMarks: { type: Number, required: true },
totalMarksOutOf: { type: Number, required: true },
percentOfMarks: { type: String, required: true },
attemptNo: { type: String, required: true },
passingMonth: { type: String, required: true },
passingYear: { type: String, required: true },
institutionName: { type: String, required: true },
educBoardName: { type: String, required: true },
pcmPercent: { type: String, required: true },
pbmPercent: { type: String, required: true },
stuQualifyingExam: { type: String, required: true },
marksObtained: { type: String, required: true },
stateRank: { type: String, required: true },
prevExamSeatNumber: { type: String, required: false },
prevTcNumber: { type: String, required: false },
hscPassedSchoolName: { type: String, required: true },
boardPattern: { type: String, required: true },
scholarshipName: { type: String, required: false },
scholarshipType: { type: String, required: false },
dteSeatType: { type: String, required: true },
dteUserPassword: { type: String, required: true },
dteUserId: { type: String, required: true },
// },
// graduationDetails: {
graduationInstitute: { type: String, required: true },
graduationBranch: { type: String, required: true },
graduationDegree: { type: String, required: true },
graduationMarksPct: { type: Number, required: true },
graduationsPassingYear: { type: String, required: true },
urbanRural: { type: String, required: true },
scholarshipNumber: { type: String, required: false },
lastSchoolCollegeAttended: { type: String, required: true },
// },
};

const StudentEducation = connector.model(
Expand All @@ -63,110 +63,110 @@ const StudentEducation = connector.model(
async function create(studentEducationData) {
const {
uid,
tenth: {
marks,
percentage,
seatNumber,
examName,
examBoard,
msOms,
meritNumberInQualifyingExam,
admittedNumber,
},
cetHscDetails: {
cetRollNo,
cetMarks,
qualifyingExamForAdmission,
stdType,
streamOpted,
mediumOfInstruction,
aggTotalMarks,
totalMarksOutOf,
percentOfMarks,
attemptNo,
passingMonth,
passingYear,
institutionName,
educBoardName,
pcmPercent,
pbmPercent,
stuQualifyingExam,
marksObtained,
stateRank,
prevExamSeatNumber,
prevTcNumber,
hscPassedSchoolName,
boardPattern,
scholarshipName,
scholarshipType,
dteSeatType,
dteUserPassword,
dteUserId,
},
graduationDetails: {
graduationInstitute,
graduationBranch,
graduationDegree,
graduationMarksPct,
graduationsPassingYear,
urbanRural,
scholarshipNumber,
lastSchoolCollegeAttended,
},
// tenth: {
marks,
percentage,
seatNumber,
examName,
examBoard,
msOms,
meritNumberInQualifyingExam,
admittedNumber,
// },
// cetHscDetails: {
cetRollNo,
cetMarks,
qualifyingExamForAdmission,
stdType,
streamOpted,
mediumOfInstruction,
aggTotalMarks,
totalMarksOutOf,
percentOfMarks,
attemptNo,
passingMonth,
passingYear,
institutionName,
educBoardName,
pcmPercent,
pbmPercent,
stuQualifyingExam,
marksObtained,
stateRank,
prevExamSeatNumber,
prevTcNumber,
hscPassedSchoolName,
boardPattern,
scholarshipName,
scholarshipType,
dteSeatType,
dteUserPassword,
dteUserId,
// },
// graduationDetails: {
graduationInstitute,
graduationBranch,
graduationDegree,
graduationMarksPct,
graduationsPassingYear,
urbanRural,
scholarshipNumber,
lastSchoolCollegeAttended,
// },
} = studentEducationData;

const stdEducation = new StudentEducation({
uid,
tenth: {
marks,
percentage,
seatNumber,
examName,
examBoard,
msOms,
meritNumberInQualifyingExam,
admittedNumber,
},
cetHscDetails: {
cetRollNo,
cetMarks,
qualifyingExamForAdmission,
stdType,
streamOpted,
mediumOfInstruction,
aggTotalMarks,
totalMarksOutOf,
percentOfMarks,
attemptNo,
passingMonth,
passingYear,
institutionName,
educBoardName,
pcmPercent,
pbmPercent,
stuQualifyingExam,
marksObtained,
stateRank,
prevExamSeatNumber,
prevTcNumber,
hscPassedSchoolName,
boardPattern,
scholarshipName,
scholarshipType,
dteSeatType,
dteUserPassword,
dteUserId,
},
graduationDetails: {
graduationInstitute,
graduationBranch,
graduationDegree,
graduationMarksPct,
graduationsPassingYear,
urbanRural,
scholarshipNumber,
lastSchoolCollegeAttended,
},
// tenth: {
marks,
percentage,
seatNumber,
examName,
examBoard,
msOms,
meritNumberInQualifyingExam,
admittedNumber,
// },
// cetHscDetails: {
cetRollNo,
cetMarks,
qualifyingExamForAdmission,
stdType,
streamOpted,
mediumOfInstruction,
aggTotalMarks,
totalMarksOutOf,
percentOfMarks,
attemptNo,
passingMonth,
passingYear,
institutionName,
educBoardName,
pcmPercent,
pbmPercent,
stuQualifyingExam,
marksObtained,
stateRank,
prevExamSeatNumber,
prevTcNumber,
hscPassedSchoolName,
boardPattern,
scholarshipName,
scholarshipType,
dteSeatType,
dteUserPassword,
dteUserId,
// },
// graduationDetails: {
graduationInstitute,
graduationBranch,
graduationDegree,
graduationMarksPct,
graduationsPassingYear,
urbanRural,
scholarshipNumber,
lastSchoolCollegeAttended,
// },
});
const stdEducationDoc = await stdEducation.save();
return stdEducationDoc;
Expand All @@ -183,7 +183,7 @@ async function read(filter, limit = 0, page = 1) {
}

async function update(filter, updateObject, options = { multi: true }) {
const updateResult = await studentEducationSchema.updateMany(
const updateResult = await StudentEducation.updateMany(
filter,
{ $set: updateObject },
options,
Expand All @@ -192,7 +192,7 @@ async function update(filter, updateObject, options = { multi: true }) {
}

async function remove(stdEducationId) {
const deleteResult = await studentEducationSchema.deleteMany(stdEducationId);
const deleteResult = await StudentEducation.deleteMany(stdEducationId);
return deleteResult.acknowledged;
}

Expand Down
4 changes: 3 additions & 1 deletion models/student/stdMedHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ async function create(studentMedicalData) {
parentsContact,
relativeContacts,
});
const medicalHistoryDoc = await medicalHistory.save();
const medicalHistoryDoc = await medicalHistory.save({
session: studentMedicalData.session,
});
return medicalHistoryDoc;
}

Expand Down
2 changes: 1 addition & 1 deletion models/student/stdPersonal.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ async function create(studentData) {
thumbUploaded,
noOfDocumentsUploaded,
});
const studentDoc = await student.save();
const studentDoc = await student.save({ session: studentData.session });
return studentDoc;
}

Expand Down
Loading