Connect
Source:
src/Prisma/Connect.ts
Bind a Connection to a Prisma Compute app, AWS Lambda Function, or
Cloudflare Worker and obtain the typed runtime client.
Connect is a single identifier that is simultaneously the binding’s
Context tag, its type, and the callable —
yield* Prisma.Connect(connection).
Provide Prisma.ConnectBinding on the host implementation so Alchemy can
register the deploy-time binding and resolve the client at runtime.
Binding a Connection
Section titled “Binding a Connection”export default Prisma.Compute( "api", { project, main: import.meta.filename }, Effect.gen(function* () { const db = yield* Prisma.Connect(connection); const sql = yield* SQL.Postgres({ url: db.databaseUrl });
return { fetch: Effect.gen(function* () { const users = yield* sql`SELECT * FROM users`; return yield* HttpServerResponse.json(users); }), }; }).pipe(Effect.provide(Prisma.ConnectBinding)),);