put models in file not schema

This commit is contained in:
Thomas Ruoff
2020-08-14 23:09:22 +02:00
parent 1ce67e881e
commit 8e1356209c
3 changed files with 42 additions and 30 deletions

14
db/booker.js Normal file
View File

@@ -0,0 +1,14 @@
import * as mongoose from 'mongoose'
const BookerSchema = new mongoose.Schema(
{
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 }
)
export default mongoose.models.Booker || mongoose.model('Booker', BookerSchema)