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()