From ebdcd5cd241ffc80062e77445118661e6282ba37 Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Sat, 22 Aug 2020 00:09:25 +0200 Subject: [PATCH] no need to use faulty regex in booker finding --- db/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/db/index.js b/db/index.js index 88f7367..3e2c10e 100644 --- a/db/index.js +++ b/db/index.js @@ -38,6 +38,13 @@ export async function getBookedDays() { .sort() } +export async function getBookingByUUID(uuid) { + await connect() + const booking = await Booking.findOne({ uuid }) + await booking.populate('booker').execPopulate() + return booking +} + export async function createBooking({ startDate, endDate, @@ -58,8 +65,7 @@ export async function createBooking({ throw new mongoose.Error.ValidationError(booking) } - const ignoreCaseEmailMatcher = new RegExp(email, 'i') - let booker = await Booker.findOne({ email: ignoreCaseEmailMatcher }).exec() + let booker = await Booker.findOne({ email }).exec() if (!booker) { booker = new Booker({ name, email, street, zip, city }) await booker.save()