further typing improvements

This commit is contained in:
Thomas Ruoff
2020-08-28 23:20:18 +02:00
committed by Thomas Ruoff
parent 90ac05a907
commit 52a68e9989
17 changed files with 94 additions and 71 deletions

View File

@@ -1,6 +1,16 @@
import * as mongoose from 'mongoose'
const BookerSchema = new mongoose.Schema(
export interface Booker
extends mongoose.SchemaTimestampsConfig,
mongoose.Document {
name: string
email: string
street: string
zip: string
city: string
}
const BookerSchema = new mongoose.Schema<Booker>(
{
name: { type: String, required: true },
email: { type: String, required: true, unique: true, minlength: 5 },
@@ -11,4 +21,6 @@ const BookerSchema = new mongoose.Schema(
{ timestamps: true, collation: { locale: 'de', strength: 1 } }
)
export default mongoose.models.Booker || mongoose.model('Booker', BookerSchema)
const Model: mongoose.Model<Booker> =
mongoose.models.Booker || mongoose.model('Booker', BookerSchema)
export default Model