re-use models when hot reloading

This commit is contained in:
Thomas Ruoff
2020-09-05 00:03:59 +02:00
committed by Thomas Ruoff
parent 654b4d706c
commit 451d0e2d78
3 changed files with 4 additions and 12 deletions

View File

@@ -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)