In this documentation, we will focus on the common API. This module includes the core of BatchJS. This API allows you to create your own custom jobs and steps using the common interface.
extends AbstractBatchEntityReaderStream
Class that reads data in batches of a specified size using PostgreSQL cursors.
| Name | Description | Type |
|---|---|---|
| options | The options for the PostgresBatchEntityReader. | PostgresBatchEntityReaderOptions |
| options.pool | The PostgreSQL connection pool. | Pool |
| options.query | SQL query to be executed (without LIMIT and OFFSET). | string |
| options.rowToEntity | Function that converts a row to an entity. | function |
protected
Fetches a batch of data using a PostgreSQL cursor.
| Name | Description | Type |
|---|---|---|
| size | The size of the batch to fetch. | number |
| Type | Description |
|---|---|
| Promise.<BatchData.<T>> | A promise that resolves with the batch of data. |
private
Initializes the cursor for the query if not already initialized.
| Type | Description |
|---|---|
| Promise.<{cursorName:string, client:PoolClient}> | A promise that resolves when the cursor is initialized. |
private
Closes the cursor and releases the client connection.
| Type | Description |
|---|---|
| Promise.<void> | A promise that resolves when the cursor is closed. |
Destroys the reader by closing the cursor and releasing resources.
| Name | Description | Type |
|---|---|---|
| error | The error that caused the destruction. | Error, null |
| callback | The callback function to be executed after destruction. | function |
extends AbstractBatchEntityWriterStream
Class that writes data in batches of a specified size in PostgreSQL databases.
| Name | Description | Type |
|---|---|---|
| options | The options for the PostgresBatchEntityWriter. | PostgresBatchEntityWriterOptions |
| options.pool | The PostgreSQL connection pool. | Pool |
| options.saveEntity | Function that saves an entity in the database. | function |
protected
Writes a batch of data to the storage.
| Name | Description | Type |
|---|---|---|
| chunk | The batch of data to write to the storage. | BatchData.<T> |
| Type | Description |
|---|---|
| Promise.<void> |