@types/pg-cursor
TypeScript icon, indicating that this package has built-in type declarations

2.7.2 • Public • Published

Installation

npm install --save @types/pg-cursor

Summary

This package contains type definitions for pg-cursor (https://github.com/brianc/node-postgres#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/pg-cursor.

index.d.ts

/// <reference types="node" />

import EventEmitter = require("events");
import { Connection, CustomTypesConfig, QueryResult } from "pg";

declare namespace Cursor {
    interface CursorQueryConfig {
        /**
         * By default rows come out as a Record<string,any>.
         * Pass the string 'array' here to receive each row as an array of values.
         */
        rowMode?: "array";
        /**
         * Custom type parsers for just this query result.
         */
        types?: CustomTypesConfig;
    }
    type ResultCallback<RowType> = (err: Error | undefined, rows: RowType[], result: QueryResult) => void;
}

declare class Cursor<Row = any> extends EventEmitter {
    constructor(query: string, values?: any[], config?: Cursor.CursorQueryConfig);
    submit: (connection: Connection) => void;
    read(maxRows: number): Promise<Row[]>;
    read(maxRows: number, callback: Cursor.ResultCallback<Row>): undefined;
    read(maxRows: number, callback?: Cursor.ResultCallback<Row>): Promise<Row[]> | undefined;
    close(): Promise<void>;
    close(callback: (err: Error) => void): undefined;
    close(callback?: (err: Error) => void): Promise<void> | undefined;

    /**
     * @deprecated Cursor.end is deprecated. Call end on the client itself to end a connection to the database.
     */
    end(callback: () => void): void;
}

export = Cursor;

Additional Details

Credits

These definitions were written by Tiogshi Laj, and Elias Fauser.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/pg-cursor

Weekly Downloads

48,594

Version

2.7.2

License

MIT

Unpacked Size

5.63 kB

Total Files

5

Last publish

Collaborators

  • types