mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-17 10:56:19 +02:00
✨ New and Improved Screens (#1151)
This commit is contained in:
parent
5461c57228
commit
997a1eec78
75 changed files with 1517 additions and 743 deletions
|
@ -1,13 +1,31 @@
|
|||
import { PrismaClient } from "@rallly/database";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
export * from "@prisma/client";
|
||||
export type * from "@prisma/client";
|
||||
|
||||
declare global {
|
||||
// allow global `var` declarations
|
||||
// eslint-disable-next-line no-var
|
||||
var prisma: PrismaClient | undefined;
|
||||
}
|
||||
const prismaClientSingleton = () => {
|
||||
return new PrismaClient().$extends({
|
||||
query: {
|
||||
poll: {
|
||||
findMany: ({ args, query }) => {
|
||||
if (!args.where?.deleted) {
|
||||
args.where = { ...args.where, deleted: false };
|
||||
}
|
||||
|
||||
export const prisma = global.prisma || new PrismaClient();
|
||||
return query(args);
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV !== "production") global.prisma = prisma;
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue