← Docs

Drizzle

Bring your own Drizzle ORM and Postgres driver. Gold Lapel provides the proxy; your existing Drizzle setup stays untouched.

Install

npm install goldlapel drizzle-orm @goldlapel/drizzle

# Install the Postgres driver you prefer — pg is the most common with Drizzle
npm install pg

As of v0.2, @goldlapel/drizzle is a peer-dependency package — install drizzle-orm and your Postgres driver yourself. We add the integration glue without pinning you to a Drizzle version.

Quick Start (node-postgres)

Start the proxy with noConnect: true (your pg.Client owns the connection), then wire Drizzle to that client:

import { drizzle } from 'drizzle-orm/node-postgres';
import { Client } from 'pg';
import * as goldlapel from 'goldlapel';

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

const client = new Client({ connectionString: gl.url });
await client.connect();

const db = drizzle(client);
const users = await db.select().from(usersTable);

await client.end();
await gl.stop();

Repeated reads serve in microseconds from Gold Lapel's L1 cache — Drizzle's query builder is unaffected.

With a schema

Pass Drizzle's options directly to drizzle() — schema, logger, and anything else drizzle-orm/node-postgres accepts:

import { drizzle } from 'drizzle-orm/node-postgres';
import { Client } from 'pg';
import * as goldlapel from 'goldlapel';
import * as schema from './schema.js';

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

const client = new Client({ connectionString: gl.url });
await client.connect();

const db = drizzle(client, { schema, logger: true });

Other drivers (postgres.js, Neon, etc.)

If you use a driver other than node-postgres, use wrapDrizzleDatasource(gl) to rewrite process.env.DATABASE_URL so whichever client you construct next picks up the proxy URL automatically:

import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import * as goldlapel from 'goldlapel';
import { wrapDrizzleDatasource } from '@goldlapel/drizzle';

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

// Rewrites process.env.DATABASE_URL to point at gl.url for any Drizzle driver
wrapDrizzleDatasource(gl);

const client = postgres(process.env.DATABASE_URL);
const db = drizzle(client);

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 Drizzle is the only consumer, pass noConnect: true so Gold Lapel doesn't open a redundant connection. Drop the flag if you want to use wrapper methods alongside Drizzle.

API

await goldlapel.start(upstream, opts?)

Factory from the core goldlapel package. Spawns the proxy and returns a GoldLapel instance. Pass noConnect: true when Drizzle is managing connections.

wrapDrizzleDatasource(gl)

Rewrites process.env.DATABASE_URL to point at gl.url. Useful when your Drizzle driver (postgres.js, Neon, PlanetScale, etc.) reads the connection string from the environment.

gl.url

Proxy connection string — pass it to your Postgres client directly, or let wrapDrizzleDatasource 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(). Drizzle options stay on drizzle():

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 Drizzle 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.

Upgrading from v0.1

v0.2 replaces the bundled drizzle()/init() helpers with a peer-dependency model. Install drizzle-orm yourself, call goldlapel.start(url, { noConnect: true }), and wire gl.url into your Drizzle client.

// v0.1 (old) — bundled drizzle() wrapper
import { drizzle } from '@goldlapel/drizzle';
const db = await drizzle({ schema });

// v0.2 (new) — peer-dep model, bring your own Drizzle and pg driver
import { drizzle } from 'drizzle-orm/node-postgres';
import { Client } from 'pg';
import * as goldlapel from 'goldlapel';

const gl = await goldlapel.start(url, { noConnect: true });
const client = new Client({ connectionString: gl.url });
await client.connect();
const db = drizzle(client, { schema });
  • drizzle-orm and your Postgres driver are now peer deps — install them alongside @goldlapel/drizzle.
  • goldlapel.start() is the factory — no more class constructors.
  • Pass noConnect: true so Gold Lapel doesn't open a redundant driver connection.
  • The bundled drizzle() wrapper is gone. For non-pg drivers, use wrapDrizzleDatasource(gl).

Requirements

  • Node.js 18+
  • Drizzle ORM
  • PostgreSQL (TCP connections only)