From e21f04ee64dfd5aecd87e1e59ed063a32b1bf750 Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Tue, 23 Aug 2022 00:33:29 +0200 Subject: [PATCH] get db and calendar bookings in parallel --- db/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db/index.ts b/db/index.ts index 39f0939..b03db5b 100644 --- a/db/index.ts +++ b/db/index.ts @@ -14,9 +14,10 @@ mongoose.connect(process.env.MONGO_URI, { export async function getBookedDays( uuidsToIngore?: string[] ): Promise { - const bookedInDatabase = await BookingModel.findBookedDays(uuidsToIngore) - const bookedInCalendar = await calendarGetBookedDays() - + const [bookedInDatabase, bookedInCalendar] = await Promise.all([ + BookingModel.findBookedDays(uuidsToIngore), + calendarGetBookedDays(), + ]) return [...bookedInDatabase, ...bookedInCalendar].filter(uniqueFilter).sort() }