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

[ADDED] Crud and services for student personal details #381

Merged
merged 1 commit into from
Oct 8, 2023
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
195 changes: 195 additions & 0 deletions models/student/std_personal.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,198 @@ const studentPersonalSchema = {

// eslint-disable-next-line no-unused-vars
const stdPersonal = connector.model("Student personal", studentPersonalSchema);

///crud operation///

// student personal details to the database
async function create(activityData){
const {
uid,
title,
firstName,
middleName,
motherName,
gender,
dob,
age,
birthPlace,
nationality,
motherTongue,
domicileState,
religion,
castCategory,
maharashtraKarnatakaBorderCandidate,
castDescription,
subCasteDescription,
nonCreamyLayerCertificateAttached,
hobby,
passportNo,
bloodGroup,
physicallyHandicapped,
studentMobNo,
studentMail,
parentMobNo,
parentMail,
perAddrDescr,
perPlotNo,
perStreetName,
perStuAddr1,
perStuAddr2,
city,
percellphone,
perpincode,
perresiphone,
permailaddress,
country,
state,
district,
tahsil,
correspondanceAddrDescr,
correspondancePlotNo,
correspondanceStreetName,
correspondanceStuAddr1,
correspondanceStuAddr2,
correspondanceCity,
correspondanceCellPhone,
correspondancePincode,
correspondanceResiPhone,
correspondanceMailAddress,
correspondanceCountry,
correspondanceState,
correspondanceDistrict,
correspondanceTahsil,
fatherDetails,
fathersOccupation,
parentsFirstName,
parentsMiddleName,
parentsLastName,
guardianMobNo,
guardianMailId,
nameAsPerTc ,
casteAsPerTc,
birthStatus,
maritalStatus,
panCardNo,
passportExpiry,
drivingLicNo,
drivingLicValidTo,
aadharCardNo,
electionCardNo,
motherMobNo,
motherEmailId,
parentIncome ,
photoUploaded,
signUploaded ,
thumbUploaded,
noOfDocumentsUploaded,
}=studentData;
const student= new student({
uid,
title,
firstName,
middleName,
motherName,
gender,
dob,
age,
birthPlace,
nationality,
motherTongue,
domicileState,
religion,
castCategory,
maharashtraKarnatakaBorderCandidate,
castDescription,
subCasteDescription,
nonCreamyLayerCertificateAttached,
hobby,
passportNo,
bloodGroup,
physicallyHandicapped,
studentMobNo,
studentMail,
parentMobNo,
parentMail,
perAddrDescr,
perPlotNo,
perStreetName,
perStuAddr1,
perStuAddr2,
city,
percellphone,
perpincode,
perresiphone,
permailaddress,
country,
state,
district,
tahsil,
correspondanceAddrDescr,
correspondancePlotNo,
correspondanceStreetName,
correspondanceStuAddr1,
correspondanceStuAddr2,
correspondanceCity,
correspondanceCellPhone,
correspondancePincode,
correspondanceResiPhone,
correspondanceMailAddress,
correspondanceCountry,
correspondanceState,
correspondanceDistrict,
correspondanceTahsil,
fatherDetails,
fathersOccupation,
parentsFirstName,
parentsMiddleName,
parentsLastName,
guardianMobNo,
guardianMailId,
nameAsPerTc ,
casteAsPerTc,
birthStatus,
maritalStatus,
panCardNo,
passportExpiry,
drivingLicNo,
drivingLicValidTo,
aadharCardNo,
electionCardNo,
motherMobNo,
motherEmailId,
parentIncome ,
photoUploaded,
signUploaded ,
thumbUploaded,
noOfDocumentsUploaded,
});
const studentDoc =await student.save();
return studentDoc;
}

// Retrieve student personal details based on a given filter and limit
async function read(filter,limit=1){
const studentDoc = await Student.find (filter).limit(limit);
return studentDoc ;
}

// update student personal details based on a given filter
async function update(filter,updateObject,options={multi:true}){
const updateStudent= await Student.updateMany(filter,{$set:updateObject},options);
return updateStudent.acknowledged;
}

// Delete student personal details based on a given filter
async function remove(filter){
const deleteStudent= await Student.deleteMany(filter).exec();
return deleteStudent.acknowledged;
}

// export crud functions

export default{
create,read,update,remove,
};



187 changes: 187 additions & 0 deletions services/student/std_personal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
import Student from "#models/student/std_personal" ;
import databaseError from "#error/database";

export async function createStudent (uid,
title,
firstName,
middleName,
motherName,
gender,
dob,
age,
birthPlace,
nationality,
motherTongue,
domicileState,
religion,
castCategory,
maharashtraKarnatakaBorderCandidate,
castDescription,
subCasteDescription,
nonCreamyLayerCertificateAttached,
hobby,
passportNo,
bloodGroup,
physicallyHandicapped,
studentMobNo,
studentMail,
parentMobNo,
parentMail,
perAddrDescr,
perPlotNo,
perStreetName,
perStuAddr1,
perStuAddr2,
city,
percellphone,
perpincode,
perresiphone,
permailaddress,
country,
state,
district,
tahsil,
correspondanceAddrDescr,
correspondancePlotNo,
correspondanceStreetName,
correspondanceStuAddr1,
correspondanceStuAddr2,
correspondanceCity,
correspondanceCellPhone,
correspondancePincode,
correspondanceResiPhone,
correspondanceMailAddress,
correspondanceCountry,
correspondanceState,
correspondanceDistrict,
correspondanceTahsil,
fatherDetails,
fathersOccupation,
parentsFirstName,
parentsMiddleName,
parentsLastName,
guardianMobNo,
guardianMailId,
nameAsPerTc ,
casteAsPerTc,
birthStatus,
maritalStatus,
panCardNo,
passportExpiry,
drivingLicNo,
drivingLicValidTo,
aadharCardNo,
electionCardNo,
motherMobNo,
motherEmailId,
parentIncome ,
photoUploaded,
signUploaded ,
thumbUploaded,
noOfDocumentsUploaded,){
const newStudent = await Student.create({
uid,
title,
firstName,
middleName,
motherName,
gender,
dob,
age,
birthPlace,
nationality,
motherTongue,
domicileState,
religion,
castCategory,
maharashtraKarnatakaBorderCandidate,
castDescription,
subCasteDescription,
nonCreamyLayerCertificateAttached,
hobby,
passportNo,
bloodGroup,
physicallyHandicapped,
studentMobNo,
studentMail,
parentMobNo,
parentMail,
perAddrDescr,
perPlotNo,
perStreetName,
perStuAddr1,
perStuAddr2,
city,
percellphone,
perpincode,
perresiphone,
permailaddress,
country,
state,
district,
tahsil,
correspondanceAddrDescr,
correspondancePlotNo,
correspondanceStreetName,
correspondanceStuAddr1,
correspondanceStuAddr2,
correspondanceCity,
correspondanceCellPhone,
correspondancePincode,
correspondanceResiPhone,
correspondanceMailAddress,
correspondanceCountry,
correspondanceState,
correspondanceDistrict,
correspondanceTahsil,
fatherDetails,
fathersOccupation,
parentsFirstName,
parentsMiddleName,
parentsLastName,
guardianMobNo,
guardianMailId,
nameAsPerTc ,
casteAsPerTc,
birthStatus,
maritalStatus,
panCardNo,
passportExpiry,
drivingLicNo,
drivingLicValidTo,
aadharCardNo,
electionCardNo,
motherMobNo,
motherEmailId,
parentIncome ,
photoUploaded,
signUploaded ,
thumbUploaded,
noOfDocumentsUploaded,
});
if (newStudent){
return newStudent;
}
throw new databaseError.DataEntryError("student");
}

export async function updateStudentById(id,data){
const updated= await Student.update({_id:id},data);
if (updated){
return updated;
}
throw new databaseError.DataEntryError("activity");
}

export async function studentList(filter){
const studentlist = await Student.read(filter,0);
return studentlist;
}

export async function deleteStudentById(id){
const deleted = await Student.remove({_id:id});
if(deleted){
return deleted;
}
throw new databaseError.DataDeleteError("activity");
}