forked from charmverse/app.charmverse.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.ts
24 lines (18 loc) · 693 Bytes
/
db.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import type { Prisma } from '@prisma/client';
import { PrismaClient } from '@prisma/client';
declare global {
// eslint-disable-next-line no-var, vars-on-top
var prisma: PrismaClient | undefined;
}
export const prisma = global.prisma
|| new PrismaClient({
// log: ['query']
});
// remember this instance of prisma in development to avoid too many clients
if (process.env.NODE_ENV === 'development') {
global.prisma = prisma;
}
export type TransactionClient = PrismaClient | Prisma.TransactionClient
// Pass a transaction from outer scope of function calling this
export type Transaction = { tx: TransactionClient }
export type OptionalTransaction = Partial<Transaction>