mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 22:47:15 +01:00
31 lines
838 B
TypeScript
31 lines
838 B
TypeScript
import * as mongoose from 'mongoose'
|
|
|
|
export interface Booker {
|
|
name: string
|
|
email: string
|
|
street: string
|
|
zip: string
|
|
city: string
|
|
}
|
|
|
|
export interface BookerDocument
|
|
extends Booker,
|
|
mongoose.SchemaTimestampsConfig,
|
|
mongoose.Document {}
|
|
|
|
export interface BookerModel extends mongoose.Model<BookerDocument> {}
|
|
|
|
const BookerSchema = new mongoose.Schema<BookerDocument>(
|
|
{
|
|
name: { type: String, required: true },
|
|
email: { type: String, required: true, unique: true, minlength: 5 },
|
|
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)
|