Skip to content

Commit

Permalink
Merge pull request #463 from tcet-opensource/461-feat-added-transacti…
Browse files Browse the repository at this point in the history
…ons-while-creating-students-details

200-Addressed-461-Use-of-Session-and-Transaction-to-maintain-acid-edi…
  • Loading branch information
Aastha-S-Rai authored Dec 27, 2023
2 parents 87924bc + e91ec5b commit a230e89
Show file tree
Hide file tree
Showing 9 changed files with 1,252 additions and 209 deletions.
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

0 comments on commit a230e89

Please sign in to comment.