daphnis/lib/prisma.ts

21 lines
668 B
TypeScript
Raw Normal View History

2024-06-29 07:02:21 +00:00
import { PrismaClient as daphnisClient } from "@/prisma/schemas/daphnis/generated/daphnis";
2024-06-29 05:22:22 +00:00
import { PrismaClient as artemisClient } from "@/prisma/schemas/artemis/generated/artemis";
2024-06-29 06:37:50 +00:00
const DaphnisSingleton = () => {
2024-06-29 07:02:21 +00:00
return new daphnisClient();
2024-06-29 05:22:22 +00:00
};
const aremisSingleton = () => {
return new artemisClient();
};
declare global {
2024-06-29 06:37:50 +00:00
var daphnis: undefined | ReturnType<typeof DaphnisSingleton>;
2024-06-29 05:22:22 +00:00
var artemis: undefined | ReturnType<typeof aremisSingleton>;
}
2024-06-29 06:37:50 +00:00
export const daphnis = globalThis.daphnis ?? DaphnisSingleton();
2024-06-29 05:22:22 +00:00
export const artemis = globalThis.artemis ?? aremisSingleton();
2024-06-29 06:37:50 +00:00
if (process.env.NODE_ENV !== "production") globalThis.daphnis = daphnis;