mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-29 18:26:34 +02:00
31 lines
738 B
TypeScript
31 lines
738 B
TypeScript
import { PrismaClient } from "@prisma/client";
|
|
|
|
export type * from "@prisma/client";
|
|
|
|
const prismaClientSingleton = () => {
|
|
return new PrismaClient().$extends({
|
|
query: {
|
|
poll: {
|
|
findMany: ({ args, query }) => {
|
|
if (!args.where?.deleted) {
|
|
args.where = { ...args.where, deleted: false };
|
|
}
|
|
|
|
return query(args);
|
|
},
|
|
},
|
|
},
|
|
});
|
|
};
|
|
|
|
export type ExtendedPrismaClient = ReturnType<typeof prismaClientSingleton>;
|
|
|
|
declare const globalThis: {
|
|
prismaGlobal: ExtendedPrismaClient;
|
|
} & typeof global;
|
|
|
|
const prisma = globalThis.prismaGlobal ?? prismaClientSingleton();
|
|
|
|
export { prisma };
|
|
|
|
if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma;
|