File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change 11import connector from "./databaseUtil" ;
22import Infrastructure from "./infrastructure" ;
3+
34connector . set ( "debug" , true ) ;
45
56const attendanceSchema = {
67 date : { type : Date , required : true } ,
78 time : { type : String , required : true } ,
9+ absentees : { type : Array } ,
810 class : Infrastructure ,
911} ;
1012
1113const Attendance = connector . model ( "Attendance" , attendanceSchema ) ;
1214
15+ async function create ( date , time , absentees ) {
16+ const attendance = new Attendance ( {
17+ date,
18+ time,
19+ absentees,
20+ } ) ;
21+ const newAttendence = await attendance . save ( ) ;
22+ return newAttendence ;
23+ }
24+
25+ async function remove ( filter ) {
26+ const res = await Attendance . findOneAndDelete ( filter ) ;
27+ return res ;
28+ }
29+
30+ async function grantAttendance ( roll , date ) {
31+ const res = await Attendance . findOneAndUpdate ( date , { $pull : { absentees : roll } } , { new : true } ) ;
32+ return res ;
33+ }
34+
1335export default {
14- Attendance ,
15- } ;
36+ create , remove , grantAttendance ,
37+ } ;
You can’t perform that action at this time.
0 commit comments