2021-03-25 19:29:24 +00:00
|
|
|
import { PrismaClient } from '@prisma/client'
|
|
|
|
|
2022-03-31 18:05:11 +00:00
|
|
|
if (!global.prisma) {
|
|
|
|
global.prisma = new PrismaClient({
|
|
|
|
log: [{ level: 'query', emit: 'event' }, 'warn', 'error']
|
|
|
|
})
|
|
|
|
global.prisma.$on('query', (e) => {
|
|
|
|
if (e.duration > 50) {
|
|
|
|
console.log('Query: ' + e.query)
|
|
|
|
console.log('Params: ' + e.params)
|
|
|
|
console.log('Duration: ' + e.duration + 'ms')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2021-03-25 19:29:24 +00:00
|
|
|
|
2021-09-30 15:46:58 +00:00
|
|
|
export default global.prisma
|