I have model of Schedule
const scheduleSchema = new mongoose.Schema({
group:{
type:mongoose.Schema.Types.ObjectId,
required:true,
ref: "Group"
},
finalCourse:{
teacher:{
type:mongoose.Schema.Types.ObjectId,
required:true,
ref: "Teacher"
},
},
extTeacher:{
type:mongoose.Schema.Types.ObjectId,
ref: "Teacher"
},
fromDate:{
type:Date,
required:true
},
toDate:{
type:Date,
},
fromHour:{
type:{
hour:Number,
minutes: Number
},
},
toHour:{
type:{
hour:Number,
minutes: Number
},
},
fromHourInt:{
type:Number
},
toHourInt:{
type:Number
},
allDay:{
type:Boolean
},
room:{
type: mongoose.Schema.Types.ObjectId,
ref: "Room"
}
})
I want to find the conflicts between schedules
The conflict can be if the teacher is in same time in both schedules
for example teacher1 at 04/06/2024 12:00-16:00 in group1
and teacher1 at 04/06/2024 14:00-18:00 in group2
The conflict can be if the group is in same time in both schedules
for exmaple group1 at 04/06/2024 12:00-16:00 with teacher1
and group1 at 04/06/2024 12:00-16:00 with teacher2
What is the best way find the conflicts?
Thanks!