import { Pool } from "mysql2/promise"; import { BatchData } from "batchjs"; import { AbstractBatchEntityWriterStream, AbstractBatchEntityWriterStreamOptions } from "../../common"; /** * @interface * Options for the MysqlBatchEntityWriter. * @extends AbstractBatchEntityWriterStreamOptions * @template T chunk entity * @template E row entity */ export interface MysqlBatchEntityWriterOptions extends AbstractBatchEntityWriterStreamOptions { pool: Pool; prepareStatement: string; entityToRow: (entity: T) => E; } /** * @class * Class that writes data in batches of a specified size into a MySQL database. * @extends AbstractBatchEntityWriterStream * @template T chunk entity * @template E row entity */ export declare class MysqlBatchEntityWriter extends AbstractBatchEntityWriterStream { private readonly pool; private readonly prepareStatement; private readonly entityToRow; /** * @constructor * @param {MysqlBatchEntityWriterOptions} options - The options for the MysqlBatchEntityWriter. * @param [options.pool] {Pool} - The MySQL connection pool. * @param [options.prepareStatement] {String} - Insert SQL prepared statement to be executed. * @param [options.entityToRow] {Function} - Function that converts an entity to a row. */ constructor(options: MysqlBatchEntityWriterOptions); /** * Writes a batch of data to the storage. * * @protected * @param {BatchData} chunk - The batch of data to write to the storage. * @returns {Promise} A promise that resolves when the batch is successfully written. * The promise should be rejected if there is an error during writing. */ protected batchWrite(chunk: BatchData): Promise; }