Effect CommunityEC
Effect Community6mo ago
3 replies
Izak Filmalter

Accessing the Underlying `postgres.js` Instance in Effect Typescript

I know this is supper hacky, is this the best way to get access to the underlying postgres.js instance?
export const getPostgresConnection = Effect.gen(function* () {
  const pgClient = yield* PgClient.PgClient

  // Access the underlying postgres connection through the acquirer
  const connection = yield* pgClient.reserve

  // The connection has a 'pg' property that contains the postgres client
  const postgresClient: postgres.Sql = (connection as any).pg

  return postgresClient
})
Was this page helpful?