@types/pg

  • Version 8.15.6
  • Published
  • 19.1 kB
  • 3 dependencies
  • MIT license

Install

npm i @types/pg
yarn add @types/pg
pnpm add @types/pg

Overview

TypeScript definitions for pg

Index

Variables

Functions

Classes

Interfaces

Type Aliases

Variables

variable defaults

const defaults: Defaults & ClientConfig;

    variable native

    const native: typeof Pg;

      variable types

      const types: any;

        Functions

        function escapeIdentifier

        escapeIdentifier: (str: string) => string;

          function escapeLiteral

          escapeLiteral: (str: string) => string;

            Classes

            class Client

            class Client extends ClientBase {}

              constructor

              constructor(config?: string | ClientConfig);

                property connection

                readonly connection: Connection;

                  property database

                  database?: string;

                    property host

                    host: string;

                      property password

                      password?: string;

                        property port

                        port: number;

                          property ssl

                          ssl: boolean;

                            property user

                            user?: string;

                              method end

                              end: { (): Promise<void>; (callback: (err: Error) => void): void };

                                class ClientBase

                                class ClientBase extends events.EventEmitter {}

                                  constructor

                                  constructor(config?: string | ClientConfig);

                                    property escapeIdentifier

                                    escapeIdentifier: (str: string) => string;

                                      property escapeLiteral

                                      escapeLiteral: (str: string) => string;

                                        property getTypeParser

                                        getTypeParser: any;

                                          property setTypeParser

                                          setTypeParser: any;

                                            method connect

                                            connect: { (): Promise<void>; (callback: (err: Error) => void): void };

                                              method copyFrom

                                              copyFrom: (queryText: string) => stream.Writable;

                                                method copyTo

                                                copyTo: (queryText: string) => stream.Readable;

                                                  method on

                                                  on: {
                                                  (event: 'drain', listener: () => void): this;
                                                  (event: 'error', listener: (err: Error) => void): this;
                                                  (event: 'notice', listener: (notice: NoticeMessage) => void): this;
                                                  (event: 'notification', listener: (message: Notification) => void): this;
                                                  (event: 'end', listener: () => void): this;
                                                  };

                                                    method pauseDrain

                                                    pauseDrain: () => void;

                                                      method query

                                                      query: {
                                                      <T extends Submittable>(queryStream: T): T;
                                                      <R extends any[] = any[], I = any[]>(
                                                      queryConfig: QueryArrayConfig<I>,
                                                      values?: QueryConfigValues<I>
                                                      ): Promise<QueryArrayResult<R>>;
                                                      <R extends QueryResultRow = any, I = any>(
                                                      queryConfig: QueryConfig<I>
                                                      ): Promise<QueryResult<R>>;
                                                      <R extends QueryResultRow = any, I = any[]>(
                                                      queryTextOrConfig: string | QueryConfig<I>,
                                                      values?: QueryConfigValues<I>
                                                      ): Promise<QueryResult<R>>;
                                                      <R extends any[] = any[], I = any[]>(
                                                      queryConfig: QueryArrayConfig<I>,
                                                      callback: (err: Error, result: QueryArrayResult<R>) => void
                                                      ): void;
                                                      <R extends QueryResultRow = any, I = any[]>(
                                                      queryTextOrConfig: string | QueryConfig<I>,
                                                      callback: (err: Error, result: QueryResult<R>) => void
                                                      ): void;
                                                      <R extends QueryResultRow = any, I = any[]>(
                                                      queryText: string,
                                                      values: QueryConfigValues<I>,
                                                      callback: (err: Error, result: QueryResult<R>) => void
                                                      ): void;
                                                      };

                                                        method resumeDrain

                                                        resumeDrain: () => void;

                                                          class Connection

                                                          class Connection extends events.EventEmitter {}

                                                            constructor

                                                            constructor(config?: ClientConfig);

                                                              property stream

                                                              readonly stream: stream.Duplex;

                                                                method bind

                                                                bind: (config: BindConfig | null, more: boolean) => void;

                                                                  method close

                                                                  close: (msg: MessageConfig, more: boolean) => void;

                                                                    method describe

                                                                    describe: (msg: MessageConfig, more: boolean) => void;

                                                                      method end

                                                                      end: () => void;

                                                                        method execute

                                                                        execute: (config: ExecuteConfig | null, more: boolean) => void;

                                                                          method flush

                                                                          flush: () => void;

                                                                            method parse

                                                                            parse: (query: QueryParse, more: boolean) => void;

                                                                              method query

                                                                              query: (text: string) => void;

                                                                                method sync

                                                                                sync: () => void;

                                                                                  class Events

                                                                                  class Events extends events.EventEmitter {}

                                                                                    method on

                                                                                    on: (event: 'error', listener: (err: Error, client: Client) => void) => this;

                                                                                      class Pool

                                                                                      class Pool extends events.EventEmitter {}

                                                                                      constructor

                                                                                      constructor(config?: PoolConfig);
                                                                                      • Every field of the config object is entirely optional. The config passed to the pool is also passed to every client instance within the pool when the pool creates that client.

                                                                                      property ended

                                                                                      readonly ended: boolean;

                                                                                        property ending

                                                                                        readonly ending: boolean;

                                                                                          property expiredCount

                                                                                          readonly expiredCount: number;

                                                                                            property idleCount

                                                                                            readonly idleCount: number;

                                                                                              property options

                                                                                              options: PoolOptions;

                                                                                                property totalCount

                                                                                                readonly totalCount: number;

                                                                                                  property waitingCount

                                                                                                  readonly waitingCount: number;

                                                                                                    method connect

                                                                                                    connect: {
                                                                                                    (): Promise<PoolClient>;
                                                                                                    (
                                                                                                    callback: (
                                                                                                    err: Error,
                                                                                                    client: PoolClient,
                                                                                                    done: (release?: any) => void
                                                                                                    ) => void
                                                                                                    ): void;
                                                                                                    };

                                                                                                      method end

                                                                                                      end: { (): Promise<void>; (callback: () => void): void };

                                                                                                        method on

                                                                                                        on: {
                                                                                                        (
                                                                                                        event: 'release' | 'error',
                                                                                                        listener: (err: Error, client: PoolClient) => void
                                                                                                        ): this;
                                                                                                        (
                                                                                                        event: 'connect' | 'acquire' | 'remove',
                                                                                                        listener: (client: PoolClient) => void
                                                                                                        ): this;
                                                                                                        };

                                                                                                          method query

                                                                                                          query: {
                                                                                                          <T extends Submittable>(queryStream: T): T;
                                                                                                          <R extends any[] = any[], I = any[]>(
                                                                                                          queryConfig: QueryArrayConfig<I>,
                                                                                                          values?: QueryConfigValues<I>
                                                                                                          ): Promise<QueryArrayResult<R>>;
                                                                                                          <R extends QueryResultRow = any, I = any[]>(
                                                                                                          queryConfig: QueryConfig<I>
                                                                                                          ): Promise<QueryResult<R>>;
                                                                                                          <R extends QueryResultRow = any, I = any[]>(
                                                                                                          queryTextOrConfig: string | QueryConfig<I>,
                                                                                                          values?: QueryConfigValues<I>
                                                                                                          ): Promise<QueryResult<R>>;
                                                                                                          <R extends any[] = any[], I = any[]>(
                                                                                                          queryConfig: QueryArrayConfig<I>,
                                                                                                          callback: (err: Error, result: QueryArrayResult<R>) => void
                                                                                                          ): void;
                                                                                                          <R extends QueryResultRow = any, I = any[]>(
                                                                                                          queryTextOrConfig: string | QueryConfig<I>,
                                                                                                          callback: (err: Error, result: QueryResult<R>) => void
                                                                                                          ): void;
                                                                                                          <R extends QueryResultRow = any, I = any[]>(
                                                                                                          queryText: string,
                                                                                                          values: QueryConfigValues<I>,
                                                                                                          callback: (err: Error, result: QueryResult<R>) => void
                                                                                                          ): void;
                                                                                                          };

                                                                                                            class Query

                                                                                                            class Query<R extends QueryResultRow = any, I extends any[] = any>
                                                                                                            extends events.EventEmitter
                                                                                                            implements Submittable {}

                                                                                                              constructor

                                                                                                              constructor(
                                                                                                              queryTextOrConfig?: string | QueryConfig<I>,
                                                                                                              callback?: (error: Error | undefined, result: ResultBuilder<R>) => void
                                                                                                              );

                                                                                                                constructor

                                                                                                                constructor(
                                                                                                                queryTextOrConfig?: string | QueryConfig<I>,
                                                                                                                values?: any[],
                                                                                                                callback?: (error: Error | undefined, result: ResultBuilder<R>) => void
                                                                                                                );

                                                                                                                  property submit

                                                                                                                  submit: (connection: Connection) => void;

                                                                                                                    method on

                                                                                                                    on: {
                                                                                                                    (event: 'row', listener: (row: R, result?: ResultBuilder<R>) => void): this;
                                                                                                                    (event: 'error', listener: (err: Error) => void): this;
                                                                                                                    (event: 'end', listener: (result: ResultBuilder<R>) => void): this;
                                                                                                                    };

                                                                                                                      class Result

                                                                                                                      class Result<R extends QueryResultRow = any> implements QueryResult<R> {}

                                                                                                                        constructor

                                                                                                                        constructor(rowMode: string, t: any);

                                                                                                                          property command

                                                                                                                          command: string;

                                                                                                                            property fields

                                                                                                                            fields: FieldDef[];

                                                                                                                              property oid

                                                                                                                              oid: number;

                                                                                                                                property rowCount

                                                                                                                                rowCount: number;

                                                                                                                                  property rows

                                                                                                                                  rows: R[];

                                                                                                                                    Interfaces

                                                                                                                                    interface BindConfig

                                                                                                                                    interface BindConfig {}

                                                                                                                                      property binary

                                                                                                                                      binary?: string | undefined;

                                                                                                                                        property portal

                                                                                                                                        portal?: string | undefined;

                                                                                                                                          property statement

                                                                                                                                          statement?: string | undefined;

                                                                                                                                            property valueMapper

                                                                                                                                            valueMapper?: ValueMapper | undefined;

                                                                                                                                              property values

                                                                                                                                              values?: Array<Buffer | null | undefined | string> | undefined;

                                                                                                                                                interface ClientConfig

                                                                                                                                                interface ClientConfig {}

                                                                                                                                                  property application_name

                                                                                                                                                  application_name?: string | undefined;

                                                                                                                                                    property client_encoding

                                                                                                                                                    client_encoding?: string | undefined;

                                                                                                                                                      property connectionString

                                                                                                                                                      connectionString?: string | undefined;

                                                                                                                                                        property connectionTimeoutMillis

                                                                                                                                                        connectionTimeoutMillis?: number | undefined;

                                                                                                                                                          property database

                                                                                                                                                          database?: string | undefined;

                                                                                                                                                            property fallback_application_name

                                                                                                                                                            fallback_application_name?: string | undefined;

                                                                                                                                                              property host

                                                                                                                                                              host?: string | undefined;

                                                                                                                                                                property idle_in_transaction_session_timeout

                                                                                                                                                                idle_in_transaction_session_timeout?: number | undefined;

                                                                                                                                                                  property keepAlive

                                                                                                                                                                  keepAlive?: boolean | undefined;

                                                                                                                                                                    property keepAliveInitialDelayMillis

                                                                                                                                                                    keepAliveInitialDelayMillis?: number | undefined;

                                                                                                                                                                      property lock_timeout

                                                                                                                                                                      lock_timeout?: number | undefined;

                                                                                                                                                                        property options

                                                                                                                                                                        options?: string | undefined;

                                                                                                                                                                          property password

                                                                                                                                                                          password?: string | (() => string | Promise<string>) | undefined;

                                                                                                                                                                            property port

                                                                                                                                                                            port?: number | undefined;

                                                                                                                                                                              property query_timeout

                                                                                                                                                                              query_timeout?: number | undefined;

                                                                                                                                                                                property ssl

                                                                                                                                                                                ssl?: boolean | ConnectionOptions | undefined;

                                                                                                                                                                                  property statement_timeout

                                                                                                                                                                                  statement_timeout?: false | number | undefined;

                                                                                                                                                                                    property stream

                                                                                                                                                                                    stream?: () => stream.Duplex | undefined;

                                                                                                                                                                                      property types

                                                                                                                                                                                      types?: CustomTypesConfig | undefined;

                                                                                                                                                                                        property user

                                                                                                                                                                                        user?: string | undefined;

                                                                                                                                                                                          interface CustomTypesConfig

                                                                                                                                                                                          interface CustomTypesConfig {}

                                                                                                                                                                                            property getTypeParser

                                                                                                                                                                                            getTypeParser: typeof pgTypes.getTypeParser;

                                                                                                                                                                                              interface Defaults

                                                                                                                                                                                              interface Defaults extends ClientConfig {}

                                                                                                                                                                                                property binary

                                                                                                                                                                                                binary?: boolean | undefined;

                                                                                                                                                                                                  property parseInputDatesAsUTC

                                                                                                                                                                                                  parseInputDatesAsUTC?: boolean | undefined;

                                                                                                                                                                                                    property parseInt8

                                                                                                                                                                                                    parseInt8?: boolean | undefined;

                                                                                                                                                                                                      property poolIdleTimeout

                                                                                                                                                                                                      poolIdleTimeout?: number | undefined;

                                                                                                                                                                                                        property poolSize

                                                                                                                                                                                                        poolSize?: number | undefined;

                                                                                                                                                                                                          property reapIntervalMillis

                                                                                                                                                                                                          reapIntervalMillis?: number | undefined;

                                                                                                                                                                                                            interface ExecuteConfig

                                                                                                                                                                                                            interface ExecuteConfig {}

                                                                                                                                                                                                              property portal

                                                                                                                                                                                                              portal?: string | undefined;

                                                                                                                                                                                                                property rows

                                                                                                                                                                                                                rows?: string | undefined;

                                                                                                                                                                                                                  interface FieldDef

                                                                                                                                                                                                                  interface FieldDef {}

                                                                                                                                                                                                                    property columnID

                                                                                                                                                                                                                    columnID: number;

                                                                                                                                                                                                                      property dataTypeID

                                                                                                                                                                                                                      dataTypeID: number;

                                                                                                                                                                                                                        property dataTypeModifier

                                                                                                                                                                                                                        dataTypeModifier: number;

                                                                                                                                                                                                                          property dataTypeSize

                                                                                                                                                                                                                          dataTypeSize: number;

                                                                                                                                                                                                                            property format

                                                                                                                                                                                                                            format: string;

                                                                                                                                                                                                                              property name

                                                                                                                                                                                                                              name: string;

                                                                                                                                                                                                                                property tableID

                                                                                                                                                                                                                                tableID: number;

                                                                                                                                                                                                                                  interface MessageConfig

                                                                                                                                                                                                                                  interface MessageConfig {}

                                                                                                                                                                                                                                    property name

                                                                                                                                                                                                                                    name?: string | undefined;

                                                                                                                                                                                                                                      property type

                                                                                                                                                                                                                                      type: string;

                                                                                                                                                                                                                                        interface Notification

                                                                                                                                                                                                                                        interface Notification {}

                                                                                                                                                                                                                                          property channel

                                                                                                                                                                                                                                          channel: string;

                                                                                                                                                                                                                                            property payload

                                                                                                                                                                                                                                            payload?: string | undefined;

                                                                                                                                                                                                                                              property processId

                                                                                                                                                                                                                                              processId: number;

                                                                                                                                                                                                                                                interface PoolClient

                                                                                                                                                                                                                                                interface PoolClient extends ClientBase {}

                                                                                                                                                                                                                                                  method release

                                                                                                                                                                                                                                                  release: (err?: Error | boolean) => void;

                                                                                                                                                                                                                                                    interface PoolConfig

                                                                                                                                                                                                                                                    interface PoolConfig extends ClientConfig {}

                                                                                                                                                                                                                                                      property allowExitOnIdle

                                                                                                                                                                                                                                                      allowExitOnIdle?: boolean | undefined;

                                                                                                                                                                                                                                                        property Client

                                                                                                                                                                                                                                                        Client?: (new () => ClientBase) | undefined;

                                                                                                                                                                                                                                                          property idleTimeoutMillis

                                                                                                                                                                                                                                                          idleTimeoutMillis?: number | undefined | null;

                                                                                                                                                                                                                                                            property log

                                                                                                                                                                                                                                                            log?: ((...messages: any[]) => void) | undefined;

                                                                                                                                                                                                                                                              property max

                                                                                                                                                                                                                                                              max?: number | undefined;

                                                                                                                                                                                                                                                                property maxLifetimeSeconds

                                                                                                                                                                                                                                                                maxLifetimeSeconds?: number | undefined;

                                                                                                                                                                                                                                                                  property maxUses

                                                                                                                                                                                                                                                                  maxUses?: number | undefined;

                                                                                                                                                                                                                                                                    property min

                                                                                                                                                                                                                                                                    min?: number | undefined;

                                                                                                                                                                                                                                                                      property Promise

                                                                                                                                                                                                                                                                      Promise?: PromiseConstructorLike | undefined;

                                                                                                                                                                                                                                                                        interface PoolOptions

                                                                                                                                                                                                                                                                        interface PoolOptions extends PoolConfig {}

                                                                                                                                                                                                                                                                          property allowExitOnIdle

                                                                                                                                                                                                                                                                          allowExitOnIdle: boolean;

                                                                                                                                                                                                                                                                            property idleTimeoutMillis

                                                                                                                                                                                                                                                                            idleTimeoutMillis: number | null;

                                                                                                                                                                                                                                                                              property max

                                                                                                                                                                                                                                                                              max: number;

                                                                                                                                                                                                                                                                                property maxLifetimeSeconds

                                                                                                                                                                                                                                                                                maxLifetimeSeconds: number;

                                                                                                                                                                                                                                                                                  property maxUses

                                                                                                                                                                                                                                                                                  maxUses: number;

                                                                                                                                                                                                                                                                                    interface QueryArrayConfig

                                                                                                                                                                                                                                                                                    interface QueryArrayConfig<I = any[]> extends QueryConfig<I> {}

                                                                                                                                                                                                                                                                                      property rowMode

                                                                                                                                                                                                                                                                                      rowMode: 'array';

                                                                                                                                                                                                                                                                                        interface QueryArrayResult

                                                                                                                                                                                                                                                                                        interface QueryArrayResult<R extends any[] = any[]> extends QueryResultBase {}

                                                                                                                                                                                                                                                                                          property rows

                                                                                                                                                                                                                                                                                          rows: R[];

                                                                                                                                                                                                                                                                                            interface QueryConfig

                                                                                                                                                                                                                                                                                            interface QueryConfig<I = any[]> {}

                                                                                                                                                                                                                                                                                              property name

                                                                                                                                                                                                                                                                                              name?: string | undefined;

                                                                                                                                                                                                                                                                                                property text

                                                                                                                                                                                                                                                                                                text: string;

                                                                                                                                                                                                                                                                                                  property types

                                                                                                                                                                                                                                                                                                  types?: CustomTypesConfig | undefined;

                                                                                                                                                                                                                                                                                                    property values

                                                                                                                                                                                                                                                                                                    values?: QueryConfigValues<I>;

                                                                                                                                                                                                                                                                                                      interface QueryParse

                                                                                                                                                                                                                                                                                                      interface QueryParse {}

                                                                                                                                                                                                                                                                                                        property name

                                                                                                                                                                                                                                                                                                        name: string;

                                                                                                                                                                                                                                                                                                          property text

                                                                                                                                                                                                                                                                                                          text: string;

                                                                                                                                                                                                                                                                                                            property types

                                                                                                                                                                                                                                                                                                            types: string[];

                                                                                                                                                                                                                                                                                                              interface QueryResult

                                                                                                                                                                                                                                                                                                              interface QueryResult<R extends QueryResultRow = any> extends QueryResultBase {}

                                                                                                                                                                                                                                                                                                                property rows

                                                                                                                                                                                                                                                                                                                rows: R[];

                                                                                                                                                                                                                                                                                                                  interface QueryResultBase

                                                                                                                                                                                                                                                                                                                  interface QueryResultBase {}

                                                                                                                                                                                                                                                                                                                    property command

                                                                                                                                                                                                                                                                                                                    command: string;

                                                                                                                                                                                                                                                                                                                      property fields

                                                                                                                                                                                                                                                                                                                      fields: FieldDef[];

                                                                                                                                                                                                                                                                                                                        property oid

                                                                                                                                                                                                                                                                                                                        oid: number;

                                                                                                                                                                                                                                                                                                                          property rowCount

                                                                                                                                                                                                                                                                                                                          rowCount: number | null;

                                                                                                                                                                                                                                                                                                                            interface QueryResultRow

                                                                                                                                                                                                                                                                                                                            interface QueryResultRow {}

                                                                                                                                                                                                                                                                                                                              index signature

                                                                                                                                                                                                                                                                                                                              [column: string]: any;

                                                                                                                                                                                                                                                                                                                                interface ResultBuilder

                                                                                                                                                                                                                                                                                                                                interface ResultBuilder<R extends QueryResultRow = any> extends QueryResult<R> {}

                                                                                                                                                                                                                                                                                                                                  method addRow

                                                                                                                                                                                                                                                                                                                                  addRow: (row: R) => void;

                                                                                                                                                                                                                                                                                                                                    interface Submittable

                                                                                                                                                                                                                                                                                                                                    interface Submittable {}

                                                                                                                                                                                                                                                                                                                                      property submit

                                                                                                                                                                                                                                                                                                                                      submit: (connection: Connection) => void;

                                                                                                                                                                                                                                                                                                                                        Type Aliases

                                                                                                                                                                                                                                                                                                                                        type ConnectionConfig

                                                                                                                                                                                                                                                                                                                                        type ConnectionConfig = ClientConfig;

                                                                                                                                                                                                                                                                                                                                          type QueryConfigValues

                                                                                                                                                                                                                                                                                                                                          type QueryConfigValues<T> = T extends Array<infer U> ? T : never;

                                                                                                                                                                                                                                                                                                                                            Package Files (1)

                                                                                                                                                                                                                                                                                                                                            Dependencies (3)

                                                                                                                                                                                                                                                                                                                                            Dev Dependencies (0)

                                                                                                                                                                                                                                                                                                                                            No dev dependencies.

                                                                                                                                                                                                                                                                                                                                            Peer Dependencies (0)

                                                                                                                                                                                                                                                                                                                                            No peer dependencies.

                                                                                                                                                                                                                                                                                                                                            Badge

                                                                                                                                                                                                                                                                                                                                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                                                                                                                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/pg.

                                                                                                                                                                                                                                                                                                                                            • Markdown
                                                                                                                                                                                                                                                                                                                                              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/pg)
                                                                                                                                                                                                                                                                                                                                            • HTML
                                                                                                                                                                                                                                                                                                                                              <a href="https://www.jsdocs.io/package/@types/pg"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>