jdkdev
06/01/2021, 4:07 PMconst prisma = new PrismaClient() once?
and then reference it throughout the api?jdkdev
06/01/2021, 4:08 PMconst { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
at the top of each file?Alan
06/01/2021, 11:32 PMreqAlan
06/01/2021, 11:33 PMreq.prisma.find...jdkdev
06/02/2021, 4:24 AMAlan
06/02/2021, 5:03 AMdeclare module 'express-serve-static-core' {
interface Request {
prisma: PrismaClient
}
}
and then
const prisma = new PrismaClient()
app.use((req: Request, res: Response, next: NextFunction) => {
req.prisma = prisma
next()
})
let me know if you found a better approach