mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 14:37:13 +01:00
re-use models when hot reloading
This commit is contained in:
committed by
Thomas Ruoff
parent
654b4d706c
commit
451d0e2d78
@@ -23,8 +23,5 @@ const BookerSchema = new mongoose.Schema<BookerDocument>(
|
||||
{ timestamps: true, collation: { locale: 'de', strength: 1 } }
|
||||
)
|
||||
|
||||
const Model = mongoose.model<BookerDocument, BookerModel>(
|
||||
'Booker',
|
||||
BookerSchema
|
||||
)
|
||||
export default Model
|
||||
export default <BookerModel>mongoose.models.Booker ||
|
||||
mongoose.model<BookerDocument, BookerModel>('Booker', BookerSchema)
|
||||
|
||||
@@ -86,9 +86,5 @@ BookingSchema.static('findBookedDays', async function (): Promise<string[]> {
|
||||
.sort()
|
||||
})
|
||||
|
||||
const Model: BookingModel = mongoose.model<BookingDocument, BookingModel>(
|
||||
'Booking',
|
||||
BookingSchema
|
||||
)
|
||||
|
||||
export default Model
|
||||
export default <BookingModel>mongoose.models.Booking ||
|
||||
mongoose.model<BookingDocument, BookingModel>('Booking', BookingSchema)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as mongoose from 'mongoose'
|
||||
import Booker from './booker'
|
||||
import Booking from './booking'
|
||||
import { BOOKING_STATUS } from './bookingStatus'
|
||||
|
||||
let connectedPromise: Promise<typeof mongoose>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user