mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-04 23:17:12 +01:00
use global for prisma
This commit is contained in:
16
db/index.ts
16
db/index.ts
@@ -1,11 +1,23 @@
|
|||||||
import { BookingStatus, Booking, PrismaClient, Prisma } from '@prisma/client'
|
import { BookingStatus, Booking, PrismaClient, Prisma } from '@prisma/client'
|
||||||
|
|
||||||
const prisma = new PrismaClient()
|
|
||||||
|
|
||||||
import { getBookedDays as calendarGetBookedDays } from '../lib/googlecalendar'
|
import { getBookedDays as calendarGetBookedDays } from '../lib/googlecalendar'
|
||||||
import { uniqueFilter } from '../helpers/array'
|
import { uniqueFilter } from '../helpers/array'
|
||||||
import { dateFormatBackend, getDays, nowInTz } from '../helpers/date'
|
import { dateFormatBackend, getDays, nowInTz } from '../helpers/date'
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
// allow global `var` declarations
|
||||||
|
// eslint-disable-next-line no-var
|
||||||
|
var prisma: PrismaClient | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
export const prisma =
|
||||||
|
global.prisma ||
|
||||||
|
new PrismaClient({
|
||||||
|
log: ['query'],
|
||||||
|
})
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV !== 'production') global.prisma = prisma
|
||||||
|
|
||||||
export async function getBookedDays(
|
export async function getBookedDays(
|
||||||
uuidsToIngore?: string[]
|
uuidsToIngore?: string[]
|
||||||
) {
|
) {
|
||||||
|
|||||||
Reference in New Issue
Block a user