File tree Expand file tree Collapse file tree 3 files changed +185
-60
lines changed Expand file tree Collapse file tree 3 files changed +185
-60
lines changed Original file line number Diff line number Diff line change 1+ import connector from "#models/databaseUtil" ;
2+
3+ const studentCollegeSchema = {
4+ uid : {
5+ type : String ,
6+ required : true ,
7+ unique : true ,
8+ } ,
9+ admissionYear : {
10+ type : String ,
11+ required : true ,
12+ } ,
13+ studentCode : {
14+ type : String ,
15+ } ,
16+ rollNo : {
17+ type : String ,
18+ } ,
19+ admissionStatus : {
20+ type : String ,
21+ required : true ,
22+ } ,
23+ admissionPattern : {
24+ type : String ,
25+ } ,
26+ admissionCategory : {
27+ type : String ,
28+ required : true ,
29+ } ,
30+ seatDesc : {
31+ type : String ,
32+ } ,
33+ quotaType : {
34+ type : String ,
35+ required : true ,
36+ } ,
37+ isBoarderStudent : {
38+ type : Boolean ,
39+ } ,
40+ seatType : {
41+ type : String ,
42+ required : true ,
43+ } ,
44+ seatSubType : {
45+ type : String ,
46+ required : true ,
47+ } ,
48+ eligibilityNo : {
49+ type : String ,
50+ required : true ,
51+ } ,
52+ enrollmentNo : {
53+ type : String ,
54+ required : true ,
55+ unique : true ,
56+ } ,
57+ } ;
58+
59+ const StudentCollege = connector . model ( "Student college" , studentCollegeSchema ) ;
60+
61+ async function create ( studentCollegeData ) {
62+ const {
63+ uid,
64+ admissionYear,
65+ studentCode,
66+ rollNo,
67+ admissionStatus,
68+ admissionPattern,
69+ admissionCategory,
70+ seatDesc,
71+ quotaType,
72+ isBoarderStudent,
73+ seatType,
74+ seatSubType,
75+ eligibilityNo,
76+ enrollmentNo,
77+ } = studentCollegeData ;
78+
79+ const stdCollege = new StudentCollege ( {
80+ uid,
81+ admissionYear,
82+ studentCode,
83+ rollNo,
84+ admissionStatus,
85+ admissionPattern,
86+ admissionCategory,
87+ seatDesc,
88+ quotaType,
89+ isBoarderStudent,
90+ seatType,
91+ seatSubType,
92+ eligibilityNo,
93+ enrollmentNo,
94+ } ) ;
95+
96+ const stdCollegeDoc = await stdCollege . save ( ) ;
97+ return stdCollegeDoc ;
98+ }
99+
100+ async function read ( filter , limit = 1 ) {
101+ const stdCollegeDoc = studentCollegeSchema . find ( filter ) . limit ( limit ) ;
102+ return stdCollegeDoc ;
103+ }
104+
105+ async function update ( filter , updateObject , options = { multi : true } ) {
106+ const updateResult = await studentCollegeSchema . updateMany (
107+ filter ,
108+ { $set : updateObject } ,
109+ options ,
110+ ) ;
111+ return updateResult . acknowledged ;
112+ }
113+
114+ async function remove ( stdCollegeId ) {
115+ const deleteResult = await studentCollegeSchema . deleteMany ( stdCollegeId ) ;
116+ return deleteResult . acknowledged ;
117+ }
118+
119+ export default {
120+ create,
121+ read,
122+ update,
123+ remove,
124+ } ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import StudentCollege from "#models/student/stdCollege" ;
2+ import databaseError from "#error/database" ;
3+
4+ export async function createStudentCollege (
5+ uid ,
6+ admissionYear ,
7+ studentCode ,
8+ rollNo ,
9+ admissionStatus ,
10+ admissionPattern ,
11+ admissionCategory ,
12+ seatDesc ,
13+ quotaType ,
14+ isBoarderStudent ,
15+ seatType ,
16+ seatSubType ,
17+ eligibilityNo ,
18+ enrollmentNo ,
19+ ) {
20+ const newStudentCollege = await StudentCollege . create ( {
21+ uid,
22+ admissionYear,
23+ studentCode,
24+ rollNo,
25+ admissionStatus,
26+ admissionPattern,
27+ admissionCategory,
28+ seatDesc,
29+ quotaType,
30+ isBoarderStudent,
31+ seatType,
32+ seatSubType,
33+ eligibilityNo,
34+ enrollmentNo,
35+ } ) ;
36+ if ( newStudentCollege . uid === uid ) {
37+ return newStudentCollege ;
38+ }
39+ throw new databaseError . DataEntryError ( "student college" ) ;
40+ }
41+
42+ export async function updateStudentCollegeById ( id , data ) {
43+ const updated = await StudentCollege . update ( { _id : id } , data ) ;
44+ if ( updated ) {
45+ return updated ;
46+ }
47+ throw new databaseError . DataEntryError ( "student college" ) ;
48+ }
49+
50+ export async function studentCollegeList ( filter ) {
51+ const studentColleges = await StudentCollege . read ( filter , 0 ) ;
52+ return studentColleges ;
53+ }
54+
55+ export async function deleteStudentCollegeById ( studentCollegeId ) {
56+ const deleted = await StudentCollege . remove ( { _id : studentCollegeId } ) ;
57+ if ( deleted ) {
58+ return deleted ;
59+ }
60+ throw new databaseError . DataDeleteError ( "student college" ) ;
61+ }
You can’t perform that action at this time.
0 commit comments