ok, bad idea. moving everything that is not a page out of pages

This commit is contained in:
Thomas Ruoff
2020-08-01 16:38:03 +02:00
parent 95242403c5
commit e4c8b7ceba
11 changed files with 6 additions and 6 deletions

45
db/schema.js Normal file
View File

@@ -0,0 +1,45 @@
import { Schema } from 'mongoose'
import { getDays, dateFormat } from '../helpers/date'
export const BookerSchema = new 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 const BookingSchema = new Schema(
{
booker: { type: Schema.Types.ObjectId, ref: 'Booker', required: true },
startDate: {
type: Date,
required: true,
get: dateFormat,
min: new Date(),
},
endDate: { type: Date, required: false, get: dateFormat, min: new Date() },
status: {
type: String,
enum: ['requested', 'confirmed', 'rejected'],
required: true,
default: 'requested',
},
purpose: { type: String, required: false },
org: { type: String, required: false },
destination: { type: String, required: false },
},
{
timestamps: true,
toJSON: { virtuals: true, getters: true },
toObject: { virtuals: true, getters: true },
}
)
BookingSchema.virtual('days').get(function () {
return getDays({ startDate: this.startDate, endDate: this.endDate })
})