PRO

Drizzle Effect Postgres Repository

A repository layer over the native Effect v4 Postgres support that Drizzle shipped in 1.0.0-rc.1. Drizzle query builders extend Effect.Effect directly, so there is no tryPromise wrapper and no execute call; this snippet uses that to place the seam at the repository, catching EffectDrizzleQueryError by tag and re-raising tagged domain errors, building the database with makeWithDefaults so only PgClient stays in the requirement channel, and composing a single Live layer whose connection string is the only place Postgres is named.

Install
npx shadcn@latest add https://ui.aryank.space/r/drizzle-effect-pg-repository.json

Installs from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.

Visualization
error seam
query
unknown
response
unknown
await db.select().from(users) // pg error surfaces as-is

The query fails and the raw driver error climbs the stack untouched, so the user's 500 page says relation users_old does not exist, complete with the table name and the SQL. The route handler never had a chance to be graceful about an error it had no type for.

Files

Dependencies