mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
generate random UUIDs for bookings
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import * as mongoose from 'mongoose'
|
||||
|
||||
const BookerSchema = new mongoose.Schema(
|
||||
{
|
||||
_id: {
|
||||
type: String,
|
||||
default: uuidv4,
|
||||
},
|
||||
name: { type: String, required: true },
|
||||
email: { type: String, required: true, unique: true, minlength: 5 },
|
||||
street: { type: String, required: true },
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import * as mongoose from 'mongoose'
|
||||
|
||||
import { getDays, dateFormatBackend } from '../helpers/date'
|
||||
|
||||
const BookingSchema = new mongoose.Schema(
|
||||
{
|
||||
_id: {
|
||||
type: String,
|
||||
default: uuidv4,
|
||||
},
|
||||
booker: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'Booker',
|
||||
@@ -42,5 +47,7 @@ BookingSchema.virtual('days').get(function () {
|
||||
return getDays({ startDate: this.startDate, endDate: this.endDate })
|
||||
})
|
||||
|
||||
BookingSchema.virtual('hash').get(function () {})
|
||||
|
||||
export default mongoose.models.Booking ||
|
||||
mongoose.model('Booking', BookingSchema)
|
||||
|
||||
Reference in New Issue
Block a user