@@ -35,6 +35,16 @@ func Collection(c *mongo.Database) {
3535// GetAllMeetings returns all meetings scheduled between given start and end time
3636func GetAllMeetings (startTime time.Time , endTime time.Time ) MeetingResponse {
3737 meetings := []Meeting {}
38+
39+ if mCollection == nil {
40+ return MeetingResponse {
41+ http .StatusOK ,
42+ "List of all Meetings" ,
43+ []Meeting {},
44+ time .Now ().UTC (),
45+ }
46+ }
47+
3848 cursor , err := mCollection .Find (context .TODO (), bson.M {
3949 "start_time" : bson.M {
4050 "$gt" : startTime ,
@@ -85,6 +95,16 @@ func CreateMeeting(meeting Meeting) MeetingResponse {
8595 CreatedAt : time .Now ().UTC (),
8696 }
8797
98+ if mCollection == nil {
99+ message := MeetingResponse {
100+ http .StatusOK ,
101+ "Meeting creating successfully." ,
102+ []Meeting {newMeeting },
103+ time .Now ().UTC (),
104+ }
105+ return message
106+ }
107+
88108 busyAccounts := checkTimeOverlap (participants , startTime , endTime )
89109
90110 if len (busyAccounts ) > 0 {
@@ -123,6 +143,17 @@ func CreateMeeting(meeting Meeting) MeetingResponse {
123143// GetMeetingForParticipant returns all meetings the given participant is inside
124144func GetMeetingForParticipant (email string ) MeetingResponse {
125145 meetings := []Meeting {}
146+
147+ if mCollection == nil {
148+ message := MeetingResponse {
149+ http .StatusOK ,
150+ "Requested Meeting/s for Participant Found" ,
151+ meetings ,
152+ time .Now ().UTC (),
153+ }
154+ return message
155+ }
156+
126157 cursor , err := mCollection .Find (context .TODO (), bson.M {
127158 "participants.email" : bson.M {
128159 "$all" : []string {email },
0 commit comments