// One client per Lambda container — a fresh client
// per invocation exhausts the RDS connection pool.
let prisma: PrismaClient | undefined;
export const getPrisma = (): PrismaClient => {
prisma ??= new PrismaClient();
return prisma;
};// field noteA Lambda that opened a fresh database client on every invocation melted our RDS connection limit during a traffic spike. One cached instance per container fixed it in four lines.
$ verdict:Use sparingly — in TypeScript a module export is already a singleton; in Go, sync.Once is the whole pattern.