← Docs

Prisma

Prisma support comes as a small companion package — @goldlapel/prisma — alongside the core wrapper. Prisma manages its own pool; Gold Lapel provides the proxy URL.

Install

npm install goldlapel @goldlapel/prisma

Two npm packages: goldlapel (the wrapper, spawns the proxy) and @goldlapel/prisma (the integration helper). @prisma/client is a peer dependency — keep your existing Prisma version. Whichever Postgres driver Prisma is configured to use (pg, postgres, or @vercel/postgres) handles the wire.

Quick start

Start the proxy with noConnect: true (Prisma manages its own pool), then point Prisma at gl.url:

import { PrismaClient } from '@prisma/client';
import * as goldlapel from 'goldlapel';

// Spawn the proxy — noConnect skips Gold Lapel's internal driver connection
// (Prisma manages its own pool)
const gl = await goldlapel.start(
  'postgresql://user:pass@localhost:5432/mydb',
  { noConnect: true }
);

// Point Prisma at the proxy URL
const prisma = new PrismaClient({
  datasources: { db: { url: gl.url } },
});

const users = await prisma.user.findMany();

await prisma.$disconnect();
await gl.stop();

Repeated reads serve in microseconds from Gold Lapel's L1 cache. Prisma's query interface is untouched.

Prisma v7+ and DATABASE_URL rewriting

Prisma v7 removed the datasources constructor override. Use wrapPrismaDatasource(gl) to rewrite process.env.DATABASE_URL before you create the client — works with v5, v6, and v7+:

import * as goldlapel from 'goldlapel';
import { wrapPrismaDatasource } from '@goldlapel/prisma';

const gl = await goldlapel.start(process.env.DATABASE_URL, { noConnect: true });

// Rewrite DATABASE_URL so Prisma (v5/v6/v7+) picks up the proxy URL automatically
wrapPrismaDatasource(gl);

const { PrismaClient } = await import('@prisma/client');
const prisma = new PrismaClient();

Why noConnect: true?

By default goldlapel.start() opens a small internal driver connection for the wrapper helpers (gl.search(), gl.docInsert(), etc.). When Prisma owns the database, you generally want Prisma to be the only thing holding connections, so pass noConnect: true. Drop the flag if you also want to use the wrapper helpers alongside Prisma.

API

await goldlapel.start(upstream, opts?)

Factory from the core goldlapel package. Spawns the proxy and returns a GoldLapel instance. Pass noConnect: true when Prisma is managing its own pool.

wrapPrismaDatasource(gl)

Rewrites process.env.DATABASE_URL to point at gl.url. Call it before creating your PrismaClient. Required for Prisma v7+; optional for v5/v6 if you prefer not to pass datasources explicitly.

gl.url

Proxy connection string — pass it to Prisma via the datasources option, or let wrapPrismaDatasource inject it into the environment.

gl.stop()

Stops the proxy. Idempotent, and runs automatically on process exit.

Options

Gold Lapel options live on goldlapel.start(). The Prisma package is a thin integration helper — Prisma options stay on the PrismaClient constructor:

const gl = await goldlapel.start('postgresql://user:pass@host:5432/mydb', {
  noConnect: true,
  port: 9000,
  extraArgs: ['--threshold-duration-ms', '200'],
  config: {
    mode: 'waiter',
    poolSize: 50,
  },
});
OptionDefaultDescription
noConnectfalseSkip Gold Lapel's internal driver connection. Recommended when Prisma is the only consumer.
port7932Local proxy port
extraArgs[]Extra CLI flags passed to the Gold Lapel binary
config{}Structured config object (mode, poolSize, etc.)

For the complete list of configuration keys, see the configuration reference.

Requirements

  • Node.js 18+
  • Prisma 5.0+ (including v7+)
  • PostgreSQL (TCP connections)

For the underlying core wrapper API — goldlapel.start(), scoped connections, and the wrapper helpers — see the JavaScript guide.