1+ import connector from "#models/databaseUtil" ;
2+
3+ const Education = {
4+ educationType : { type : String , required : true } ,
5+ educationName : { type : String , required : true } ,
6+ specialization : { type : String , required : true } ,
7+ period : { type : String , required : true } ,
8+ institutionName : { type : String , required : true } ,
9+ university : { type : String , required : true } ,
10+ passingDivision : { type : String , required : true } ,
11+ fromYear : { type : String , required : true } ,
12+ uptoYear : { type : String , required : true } ,
13+ registrationNumber : { type : String , required : true } ,
14+ aggregatePct : { type : String , required : true } ,
15+ finalYearPct : { type : String , required : true } ,
16+ numberOfAttempts : { type : Number , required : true } ,
17+ rank : { type : Number , required : true } ,
18+ passingYear : { type : String , required : true } ,
19+ } ;
20+ const employeeEducationHistorySchema = {
21+ uid : { type : String , require : true } ,
22+ ssc : { type : Education , required : true } ,
23+ hsc : { type : Education , required : true } ,
24+ dip : { type : Education } ,
25+ iti : { type : Education } ,
26+ deg : { type : Education } ,
27+ pgd : { type : Education } ,
28+ phd : { type : Education } ,
29+ pdoc : { type : Education } ,
30+ } ;
31+
32+ // eslint-disable-next-line no-unused-vars
33+ const EmployeeEducationHistory =
34+ connector . model ( "Employee education history" ,
35+ employeeEducationHistorySchema ) ;
36+
37+ //CRUD Operations
38+
39+ async function create ( employeeEducationHistoryData ) {
40+ const {
41+ educationType,
42+ educationName,
43+ specialization,
44+ period,
45+ institutionName,
46+ university,
47+ passingDivision,
48+ fromYear,
49+ uptoYear,
50+ registrationNumber,
51+ aggregatePct,
52+ finalYearPct,
53+ numberOfAttempts,
54+ rank,
55+ passingYear,
56+ uid,
57+ ssc,
58+ hsc,
59+ dip,
60+ iti,
61+ deg,
62+ pgd,
63+ phd,
64+ pdoc,
65+ } = employeeEducationHistoryData ;
66+
67+ const empEduHistory = new EmployeeEducationHistory ( {
68+ educationType,
69+ educationName,
70+ specialization,
71+ period,
72+ institutionName,
73+ university,
74+ passingDivision,
75+ fromYear,
76+ uptoYear,
77+ registrationNumber,
78+ aggregatePct,
79+ finalYearPct,
80+ numberOfAttempts,
81+ rank,
82+ passingYear,
83+ uid,
84+ ssc,
85+ hsc,
86+ dip,
87+ iti,
88+ deg,
89+ pgd,
90+ phd,
91+ pdoc,
92+ } ) ;
93+
94+ const empEduHistoryDoc = await empEduHistory . save ( ) ;
95+ return empEduHistoryDoc ;
96+ }
97+
98+
99+ async function read ( filter , limit = 1 ) {
100+ const empEduHistoryDoc = employeeEducationHistorySchema . find ( filter ) . limit ( limit ) ;
101+ return empEduHistoryDoc ;
102+ }
103+
104+
105+ async function update ( filter , updateObject , options = { multi : true } ) {
106+ const updateResult = await employeeEducationHistorySchema . updateMany (
107+ filter ,
108+ { $set : updateObject } ,
109+ options ,
110+ ) ;
111+ return updateResult . acknowledged ;
112+ }
113+
114+ async function remove ( filter ) {
115+ const deleteResult = await employeeEducationHistorySchema . deleteMany ( filter ) . exec ( ) ;
116+ return deleteResult . acknowledged ;
117+ }
118+
119+ export default {
120+ create, read, update, remove,
121+ } ;
0 commit comments