Prisma
Bring your own Prisma. Gold Lapel provides the proxy, Prisma handles the pool.
Install
npm install goldlapel @prisma/client @goldlapel/prisma pg
# or: npm install goldlapel @prisma/client @goldlapel/prisma postgres
# or: npm install goldlapel @prisma/client @goldlapel/prisma @vercel/postgres As of v0.2, @goldlapel/prisma is a separate npm package with a peer dependency on @prisma/client. Install Prisma yourself — our package adds the integration glue so you stay in control of Prisma's version. goldlapel itself is driver-agnostic — install whichever Postgres driver Prisma is configured to use (pg, postgres, or @vercel/postgres); pg is the most common.
Quick Start
Start the proxy with noConnect: true (Prisma owns its own connection pool), then point Prisma at gl.url:
import { PrismaClient } from '@prisma/client';
import * as goldlapel from 'goldlapel';
import { wrapPrismaDatasource } from '@goldlapel/prisma';
// 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 Gold Lapel's wrapper methods (gl.search(), gl.docInsert(), etc.). When Prisma owns the database, you usually want Prisma to be the only thing holding connections, so pass noConnect: true. If you do want to use wrapper methods alongside Prisma, drop the flag.
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 are set on goldlapel.start(). The Prisma package is a thin integration — 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,
},
}); | Option | Default | Description |
|---|---|---|
noConnect | false | Skip Gold Lapel's internal driver connection. Recommended when Prisma is the only consumer. |
port | 7932 | Local 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.
Upgrading from v0.1
v0.2 replaces the bundled withGoldLapel()/init() helpers with a peer-dependency model. Bring your own @prisma/client, call goldlapel.start(url, { noConnect: true }), and wire gl.url into your PrismaClient.
// v0.1 (old) — single package, class constructor
import { GoldLapel } from '@goldlapel/goldlapel';
import { withGoldLapel } from '@goldlapel/prisma';
const prisma = await withGoldLapel();
const users = await prisma.user.findMany();
// v0.2 (new) — peer-dep, factory API, bring your own Prisma
import { PrismaClient } from '@prisma/client';
import * as goldlapel from 'goldlapel';
import { wrapPrismaDatasource } from '@goldlapel/prisma';
const gl = await goldlapel.start(url, { noConnect: true });
const prisma = new PrismaClient({ datasources: { db: { url: gl.url } } });
const users = await prisma.user.findMany(); @prisma/clientis now a peer dep — install it alongside@goldlapel/prisma.goldlapel.start()is the factory — no morenew GoldLapel().- Pass
noConnect: trueso Gold Lapel doesn't open a redundant driver connection. withGoldLapel()is gone. For v7+ or env-based configs, usewrapPrismaDatasource(gl).
Requirements
- Node.js 18+
- Prisma 5.0+ (including v7+)
- PostgreSQL (TCP connections only)