import { Pool } from "pg"; import { AbstractBatchEntityReaderStream, AbstractBatchEntityReaderStreamOptions } from "../../common/index"; import { BatchData } from "batchjs"; /** * @interface * Options for the PostgresBatchEntityReader. * @extends AbstractBatchEntityReaderStreamOptions * @template T chunk entity * @template E row entity */ export interface PostgresBatchEntityReaderOptions extends AbstractBatchEntityReaderStreamOptions { pool: Pool; query: string; rowToEntity: (row: E) => T; } /** * @class * Class that reads data in batches of a specified size using PostgreSQL cursors. * @extends AbstractBatchEntityReaderStream * @template T chunk entity * @template E row entity */ export declare class PostgresBatchEntityReader extends AbstractBatchEntityReaderStream { private readonly pool; private readonly query; private readonly rowToEntity; private client; private cursorName; private cursorOpened; /** * @constructor * @param {PostgresBatchEntityReaderOptions} options - The options for the PostgresBatchEntityReader. * @param [options.pool] {Pool} - The PostgreSQL connection pool. * @param [options.query] {string} - SQL query to be executed (without LIMIT and OFFSET). * @param [options.rowToEntity] {Function} - Function that converts a row to an entity. */ constructor(options: PostgresBatchEntityReaderOptions); /** * Fetches a batch of data using a PostgreSQL cursor. * * @protected * @param {number} size - The size of the batch to fetch. * @returns {Promise>} A promise that resolves with the batch of data. */ protected fetch(size: number): Promise>; /** * Initializes the cursor for the query if not already initialized. * * @private * @returns {Promise<{cursorName:string,client:PoolClient}>} A promise that resolves when the cursor is initialized. */ private initializeCursor; /** * Closes the cursor and releases the client connection. * * @private * @returns {Promise} A promise that resolves when the cursor is closed. */ private closeCursor; /** * Destroys the reader by closing the cursor and releasing resources. * * @param {Error|null} error - The error that caused the destruction. * @param {Function} callback - The callback function to be executed after destruction. */ _destroy(error: Error | null, callback: (error?: Error | null) => void): void; }