PgClient overview
Added in v1.0.0
Table of contents
constructor
makeCompiler
Signature
export declare const makeCompiler: (transform?: (_: string) => string, transformJson?: boolean) => Statement.Compiler
Added in v1.0.0
constructors
PgClientConfig (interface)
Signature
export interface PgClientConfig {
readonly url?: Redacted.Redacted | undefined
readonly host?: string | undefined
readonly port?: number | undefined
readonly path?: string | undefined
readonly ssl?: boolean | ConnectionOptions | undefined
readonly database?: string | undefined
readonly username?: string | undefined
readonly password?: Redacted.Redacted | undefined
/**
* A function returning a custom socket to use. This parameter is not documented
* in the postgres.js's type signature. See their
* [readme](https://github.com/porsager/postgres?tab=readme-ov-file#connection-details) instead.
*
* @example
* import { AuthTypes, Connector } from "@google-cloud/cloud-sql-connector";
* import { PgClient } from "@effect/sql-pg";
* import { Config, Effect, Layer } from "effect"
*
* const layer = Effect.gen(function*() {
* const connector = new Connector();
* const clientOpts = yield* Effect.promise(() => connector.getOptions({
* instanceConnectionName: "project:region:instance",
* authType: AuthTypes.IAM,
* }));
* return PgClient.layer({ socket: clientOpts.stream, username: "iam-user" });
* }).pipe(Layer.unwrapEffect)
*/
readonly socket?: (() => NodeStream.Duplex) | undefined
readonly idleTimeout?: Duration.DurationInput | undefined
readonly connectTimeout?: Duration.DurationInput | undefined
readonly maxConnections?: number | undefined
readonly connectionTTL?: Duration.DurationInput | undefined
readonly applicationName?: string | undefined
readonly spanAttributes?: Record<string, unknown> | undefined
readonly transformResultNames?: ((str: string) => string) | undefined
readonly transformQueryNames?: ((str: string) => string) | undefined
readonly transformJson?: boolean | undefined
readonly fetchTypes?: boolean | undefined
readonly prepare?: boolean | undefined
/**
* A callback when postgres has a notice, see
* [readme](https://github.com/porsager/postgres?tab=readme-ov-file#connection-details).
* By default, postgres.js logs these with console.log.
* To silence notices, see the following example:
* @example
* import { PgClient } from "@effect/sql-pg";
* import { Config, Layer } from "effect"
*
* const layer = PgClient.layer({ onnotice: Config.succeed(() => {}) })
*/
readonly onnotice?: (notice: postgres.Notice) => void
readonly types?: Record<string, postgres.PostgresType> | undefined
readonly debug?: postgres.Options<{}>["debug"] | undefined
}
Added in v1.0.0
make
Signature
export declare const make: (options: PgClientConfig) => Effect.Effect<PgClient, SqlError, Scope.Scope>
Added in v1.0.0
custom types
PgCustom (type alias)
Signature
export type PgCustom = PgJson | PgArray
Added in v1.0.0
layers
layer
Signature
export declare const layer: (config: PgClientConfig) => Layer.Layer<PgClient | Client.SqlClient, ConfigError | SqlError>
Added in v1.0.0
layerConfig
Signature
export declare const layerConfig: (
config: Config.Config.Wrap<PgClientConfig>
) => Layer.Layer<PgClient | Client.SqlClient, ConfigError | SqlError>
Added in v1.0.0
models
PgClient (interface)
Signature
export interface PgClient extends Client.SqlClient {
readonly [TypeId]: TypeId
readonly config: PgClientConfig
readonly json: (_: unknown) => Fragment
readonly array: (_: ReadonlyArray<Primitive>) => Fragment
readonly listen: (channel: string) => Stream.Stream<string, SqlError>
readonly notify: (channel: string, payload: string) => Effect.Effect<void, SqlError>
}
Added in v1.0.0
tags
PgClient
Signature
export declare const PgClient: any
Added in v1.0.0
type ids
TypeId
Signature
export declare const TypeId: typeof TypeId
Added in v1.0.0
TypeId (type alias)
Signature
export type TypeId = typeof TypeId
Added in v1.0.0