From 8c3149e7624d2860f4479d3bd8dc85332582c464 Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Thu, 20 Aug 2020 23:21:48 +0200 Subject: [PATCH] use uuid only additionally for booking --- context/appStore.js | 2 +- db/booker.js | 5 ----- db/booking.js | 3 ++- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/context/appStore.js b/context/appStore.js index 177edce..5175973 100644 --- a/context/appStore.js +++ b/context/appStore.js @@ -157,7 +157,7 @@ export default function AppStore({ children }) { const bookingData = await createBooking(state.formData) dispatch({ type: ACTIONS.POST_DATA_SUCCESS, payload: bookingData }) - router.push('/booking/[id]', `/booking/${bookingData._id}`) + router.push('/booking/[id]', `/booking/${bookingData.uuid}`) } catch (error) { console.error(error) dispatch({ type: ACTIONS.POST_DATA_ERROR, payload: error.message }) diff --git a/db/booker.js b/db/booker.js index 4fc45bf..99a11d1 100644 --- a/db/booker.js +++ b/db/booker.js @@ -1,12 +1,7 @@ -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 83110f6..0d716e6 100644 --- a/db/booking.js +++ b/db/booking.js @@ -5,7 +5,8 @@ import { getDays, dateFormatBackend } from '../helpers/date' const BookingSchema = new mongoose.Schema( { - _id: { + // need a seperate uuid to be able to target a booking anonimously + uuid: { type: String, default: uuidv4, },