mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user