UNPKG

@types/pg-cursor

Version:
57 lines (46 loc) 2.12 kB
# 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](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/pg-cursor/index.d.ts) ````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 * Last updated: Tue, 07 Nov 2023 09:09:39 GMT * Dependencies: [@types/node](https://npmjs.com/package/@types/node), [@types/pg](https://npmjs.com/package/@types/pg) # Credits These definitions were written by [Tiogshi Laj](https://github.com/Tiogshi), and [Elias Fauser](https://github.com/elias-fauser).