diff --git a/db/booker.js b/db/booker.js index 99a11d1..4fc45bf 100644 --- a/db/booker.js +++ b/db/booker.js @@ -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 }, diff --git a/db/booking.js b/db/booking.js index da686d2..83110f6 100644 --- a/db/booking.js +++ b/db/booking.js @@ -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) diff --git a/package-lock.json b/package-lock.json index d512921..4fb605c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11541,9 +11541,7 @@ "uuid": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==", - "dev": true, - "optional": true + "integrity": "sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==" }, "v8-compile-cache": { "version": "2.1.1", diff --git a/package.json b/package.json index 4013946..7b080d2 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "react-day-picker": "^7.4.8", "react-dom": "16.13.1", "rebass": "^4.0.7", - "swr": "^0.3.0" + "swr": "^0.3.0", + "uuid": "^8.3.0" }, "devDependencies": { "babel-jest": "^26.3.0",