mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 22:47:15 +01:00
32 lines
865 B
TypeScript
32 lines
865 B
TypeScript
import * as mongoose from 'mongoose'
|
|
|
|
export type Booker = {
|
|
name: string
|
|
email: string
|
|
phone: string
|
|
street: string
|
|
zip: string
|
|
city: string
|
|
}
|
|
|
|
export type BookerDocument = Booker &
|
|
mongoose.SchemaTimestampsConfig &
|
|
mongoose.Document
|
|
|
|
export type BookerModel = mongoose.Model<BookerDocument>
|
|
|
|
const BookerSchema = new mongoose.Schema<BookerDocument>(
|
|
{
|
|
name: { type: String, required: true },
|
|
email: { type: String, required: true, unique: true, minlength: 5 },
|
|
phone: { type: String, required: false },
|
|
street: { type: String, required: true },
|
|
zip: { type: String, required: true },
|
|
city: { type: String, required: true },
|
|
},
|
|
{ timestamps: true, collation: { locale: 'de', strength: 1 } }
|
|
)
|
|
|
|
export default <BookerModel>mongoose.models.Booker ||
|
|
mongoose.model<BookerDocument, BookerModel>('Booker', BookerSchema)
|