Skip to content

Commit

Permalink
Connection limit for Pg
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshshettyin committed Feb 25, 2025
1 parent 50f7b58 commit 061da31
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/services/pgConnect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import PrismaClientManager from "./pgSingelton";
import { PrismaClient } from "@prisma/client";

const prisma = PrismaClientManager.getInstance().getPrismaClient();
const globalForPrisma = global as unknown as { prisma?: PrismaClient };

export default prisma;
const prisma = globalForPrisma.prisma ?? new PrismaClient();

if (process.env.NODE_ENV !== "production") {
globalForPrisma.prisma = prisma;
}

export default prisma;
1 change: 1 addition & 0 deletions pg-worker/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ generator client {
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
connection_limit = 5
}

model user {
Expand Down
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ generator client {
datasource db {
provider = "postgresql"
url = env("PG_DATABASE_URL")
connection_limit = 5
}

model user {
Expand Down

0 comments on commit 061da31

Please sign in to comment.