Skip to content

PgClient

13 exports Added in v1.0.0 Source

Constructor

makeCompiler

Added in v1.0.0 Source

Signature

declare function makeCompiler(transform?: (_: string) => string, transformJson: boolean): Compiler;

Constructors

fromPool

Added in v1.0.0 Source

Create a PgClient from an existing pg pool.

You control the pool lifecycle via acquire (typically Effect.acquireRelease).

Signature

declare const fromPool: (
  ...args: [options: PgClientFromPoolOptions]
) => Effect<PgClient, SqlError, any>;

make

Added in v1.0.0 Source

Signature

declare function make(options: PgClientConfig): Effect<PgClient, SqlError, any>;

PgClientConfig interface

Added in v1.0.0 Source

Signature

interface PgClientConfig {
  readonly applicationName?: string;
  readonly connectionTTL?: any;
  readonly connectTimeout?: any;
  readonly database?: string;
  readonly host?: string;
  readonly idleTimeout?: any;
  readonly maxConnections?: number;
  readonly minConnections?: number;
  readonly password?: Redacted<string>;
  readonly path?: string;
  readonly port?: number;
  readonly spanAttributes?: Record<string, unknown>;
  readonly ssl?: any;
  readonly stream?: () => Duplex;
  readonly transformJson?: boolean;
  readonly transformQueryNames?: (str: string) => string;
  readonly transformResultNames?: (str: string) => string;
  readonly types?: any;
  readonly url?: Redacted<string>;
  readonly username?: string;
}

PgClientFromPoolOptions interface

Added in v1.0.0 Source

Signature

interface PgClientFromPoolOptions {
  readonly acquire: Effect<Pool, SqlError, Scope>;
  readonly applicationName?: string;
  readonly spanAttributes?: Record<string, unknown>;
  readonly transformJson?: boolean;
  readonly transformQueryNames?: (str: string) => string;
  readonly transformResultNames?: (str: string) => string;
  readonly types?: any;
}

Custom Types

PgCustom type

Added in v1.0.0 Source

Signature

type PgCustom = PgJson;

Layers

layer

Added in v1.0.0 Source

Signature

declare function layer(config: PgClientConfig): Layer<any, SqlError>;

layerConfig

Added in v1.0.0 Source

Signature

declare function layerConfig(config: Wrap<PgClientConfig>): Layer<any, any>;

Signature

declare function layerFromPool(options: PgClientFromPoolOptions): Layer<any, SqlError>;

Models

PgClient interface

Added in v1.0.0 Source

Signature

interface PgClient extends unknown {
  readonly "~@effect/sql-pg/PgClient": "~@effect/sql-pg/PgClient";
  readonly config: PgClientConfig;
  readonly json: (_: unknown) => Fragment;
  readonly listen: (channel: string) => Stream<string, SqlError>;
  readonly notify: (channel: string, payload: string) => Effect<void, SqlError>;
}

Tags

PgClient

Added in v1.0.0 Source

Signature

declare const PgClient: any;

Type Ids

TypeId

Added in v1.0.0 Source

Signature

declare const TypeId: TypeId;

TypeId type

Added in v1.0.0 Source

Signature

type TypeId = "~@effect/sql-pg/PgClient";