feat(drizzle): expose vanilla node-postgres client on Drizzle.postgres#280
Open
anaydot wants to merge 2 commits into
Open
feat(drizzle): expose vanilla node-postgres client on Drizzle.postgres#280anaydot wants to merge 2 commits into
anaydot wants to merge 2 commits into
Conversation
Adds `db.raw` to the object returned by `Drizzle.postgres(...)`. It
yields a vanilla `drizzle-orm/node-postgres` instance backed by the
same connection string. Use it for libraries that need a regular
promise-shaped drizzle (e.g. better-auth's `drizzleAdapter`):
```ts
const db = yield* Drizzle.postgres(hd.connectionString);
const raw = yield* db.raw;
const auth = betterAuth({
database: drizzleAdapter(raw, { provider: "pg", schema }),
});
```
The drizzle client is cached per-`ExecutionContext` so the pool is
built at most once per request.
309ec1e to
f8b5929
Compare
sam-goodwin
reviewed
May 11, 2026
Comment on lines
+107
to
+115
| return new Proxy(effectDb as any, { | ||
| get(target, prop, receiver) { | ||
| if (prop === "raw") return raw; | ||
| return Reflect.get(target, prop, receiver); | ||
| }, | ||
| }) as EffectPgDatabase<TRelations> & { | ||
| $client: PgClient.PgClient; | ||
| raw: Effect.Effect<NodePgDatabase<TRelations>, E, R | ExecutionContext>; | ||
| }; |
Contributor
There was a problem hiding this comment.
Why is it not using proxyChain helper anymore?
Author
There was a problem hiding this comment.
Restructured — .raw moved out of Drizzle.postgres entirely and into a new Drizzle.postgresRaw export, per the tree-shaking feedback on #281 (comment).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #274 — building block for a
BetterAuth.DrizzlePostgreslayer (separate PR).Adds
Drizzle.postgresRaw(...)— a vanilladrizzle-orm/node-postgresclient for libraries that need a regular promise-shaped drizzle (e.g. better-auth'sdrizzleAdapter).Lives in its own module so apps using only the Effect-flavored
Drizzle.postgresdon't pulldrizzle-orm/node-postgresinto the bundle. The drizzle client is cached per-ExecutionContext— the pool is built at most once per request.