mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-04 15:07:13 +01:00
make form just simple
This commit is contained in:
42
db/schema.js
42
db/schema.js
@@ -1,18 +1,34 @@
|
||||
import { Schema } from 'mongoose'
|
||||
|
||||
export const BookerSchema = new Schema({
|
||||
name: { type: String, required: true },
|
||||
email: { type: String, required: true },
|
||||
})
|
||||
import { getDays, dateFormat } from '../lib/dateHelper'
|
||||
|
||||
export const BookingSchema = new Schema({
|
||||
booker: { type: Schema.Types.ObjectId, ref: 'Booker', required: true },
|
||||
startDate: { type: Date, required: true },
|
||||
endDate: { type: Date, required: false },
|
||||
status: {
|
||||
type: String,
|
||||
enum: ['requested', 'confirmed', 'rejected'],
|
||||
required: true,
|
||||
default: 'requested',
|
||||
export const BookerSchema = new Schema(
|
||||
{
|
||||
name: { type: String, required: true },
|
||||
email: { type: String, required: true, unique: true },
|
||||
},
|
||||
{ timestamps: true }
|
||||
)
|
||||
|
||||
export const BookingSchema = new Schema(
|
||||
{
|
||||
booker: { type: Schema.Types.ObjectId, ref: 'Booker', required: true },
|
||||
startDate: {
|
||||
type: Date,
|
||||
required: true,
|
||||
get: dateFormat,
|
||||
},
|
||||
endDate: { type: Date, required: false, get: dateFormat },
|
||||
status: {
|
||||
type: String,
|
||||
enum: ['requested', 'confirmed', 'rejected'],
|
||||
required: true,
|
||||
default: 'requested',
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
)
|
||||
|
||||
BookingSchema.virtual('days').get(function () {
|
||||
return getDays({ startDate: this.startDate, endDate: this.endDate })
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user