feat: upgrade to Mongoose 9 and adjust middleware

Update `mongoose` to v9.1.5 and convert middleware hooks.

Co-authored-by: Thomas Ruoff <111471+tomru@users.noreply.github.com>
This commit is contained in:
v0
2026-02-06 07:17:37 +00:00
committed by Thomas Ruoff
parent 29a5d638e9
commit 90d9ab2d67
4 changed files with 7744 additions and 6 deletions

View File

@@ -101,16 +101,15 @@ const BookingSchema = new mongoose.Schema(
}
)
BookingSchema.pre('validate', function (next: () => void): void {
BookingSchema.pre('validate', function (): void {
const booking = this
booking.days = getDays({
startDate: new Date(booking.startDate),
endDate: new Date(booking.endDate),
})
next()
})
BookingSchema.pre('save', async function (next: () => void): Promise<void> {
BookingSchema.pre('save', async function (): Promise<void> {
const booking = this
if (!booking.calendarEventId) {
@@ -122,8 +121,6 @@ BookingSchema.pre('save', async function (next: () => void): Promise<void> {
// event has been canceled or rejected, delete calendar event again to free up the slot
await deleteCalendarEvent(booking.toJSON())
}
next()
})
BookingSchema.static(