mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +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 } }
|
{ timestamps: true, collation: { locale: 'de', strength: 1 } }
|
||||||
)
|
)
|
||||||
|
|
||||||
const Model = mongoose.model<BookerDocument, BookerModel>(
|
export default <BookerModel>mongoose.models.Booker ||
|
||||||
'Booker',
|
mongoose.model<BookerDocument, BookerModel>('Booker', BookerSchema)
|
||||||
BookerSchema
|
|
||||||
)
|
|
||||||
export default Model
|
|
||||||
|
|||||||
@@ -86,9 +86,5 @@ BookingSchema.static('findBookedDays', async function (): Promise<string[]> {
|
|||||||
.sort()
|
.sort()
|
||||||
})
|
})
|
||||||
|
|
||||||
const Model: BookingModel = mongoose.model<BookingDocument, BookingModel>(
|
export default <BookingModel>mongoose.models.Booking ||
|
||||||
'Booking',
|
mongoose.model<BookingDocument, BookingModel>('Booking', BookingSchema)
|
||||||
BookingSchema
|
|
||||||
)
|
|
||||||
|
|
||||||
export default Model
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import * as mongoose from 'mongoose'
|
import * as mongoose from 'mongoose'
|
||||||
import Booker from './booker'
|
import Booker from './booker'
|
||||||
import Booking from './booking'
|
import Booking from './booking'
|
||||||
import { BOOKING_STATUS } from './bookingStatus'
|
|
||||||
|
|
||||||
let connectedPromise: Promise<typeof mongoose>
|
let connectedPromise: Promise<typeof mongoose>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user