mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-04 06:57:12 +01:00
no need to use faulty regex in booker finding
This commit is contained in:
10
db/index.js
10
db/index.js
@@ -38,6 +38,13 @@ export async function getBookedDays() {
|
|||||||
.sort()
|
.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({
|
export async function createBooking({
|
||||||
startDate,
|
startDate,
|
||||||
endDate,
|
endDate,
|
||||||
@@ -58,8 +65,7 @@ export async function createBooking({
|
|||||||
throw new mongoose.Error.ValidationError(booking)
|
throw new mongoose.Error.ValidationError(booking)
|
||||||
}
|
}
|
||||||
|
|
||||||
const ignoreCaseEmailMatcher = new RegExp(email, 'i')
|
let booker = await Booker.findOne({ email }).exec()
|
||||||
let booker = await Booker.findOne({ email: ignoreCaseEmailMatcher }).exec()
|
|
||||||
if (!booker) {
|
if (!booker) {
|
||||||
booker = new Booker({ name, email, street, zip, city })
|
booker = new Booker({ name, email, street, zip, city })
|
||||||
await booker.save()
|
await booker.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user