Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
feat: chunkSize for IWithPostgresOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Kloubert committed Jan 7, 2024
1 parent f2c463e commit a0e3f7d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log (@egomobile/orm-pg)

## 0.21.0

- add `chunkSize` to [IWithPostgresOptions interface](https://egomobile.github.io/node-orm-pg/interfaces/IWithPostgresOptions.html)

## 0.20.0

- update to version `^0.14.0` of [node-orm](https://github.com/egomobile/node-orm)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egomobile/orm-pg",
"version": "0.20.0",
"version": "0.21.0",
"description": "A PostgreSQL data adapter and other utilities for @egomobile/orm module.",
"main": "lib/index.js",
"engines": {
Expand Down
9 changes: 8 additions & 1 deletion src/utils/withPostgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ export interface IWithPostgresConnection {
* Options for a 'withPostgres()' function.
*/
export interface IWithPostgresOptions {
/**
* Custom chunk size for cursor operations.
*
* @default `100`
*/
chunkSize?: Nilable<number>;
/**
* Run action in transaction or not.
*/
Expand Down Expand Up @@ -193,6 +199,7 @@ export function createWithPostgres<TConnections extends WithPostgresConnections
};
}

const adapterChunkSize = options?.chunkSize ?? customChunkSize;
const shouldUseRunInTransaction = !!options?.withTransaction;

let clientClass: Constructor<any> = pg.Client;
Expand All @@ -214,7 +221,7 @@ export function createWithPostgres<TConnections extends WithPostgresConnections
try {
const context = await createDataContext({
"adapter": new PostgreSQLDataAdapter({
"chunkSize": customChunkSize,
"chunkSize": adapterChunkSize,
"client": client as PostgreSQLClientLike,
"cursorClass": customCursorClass
}) as IDataAdapter,
Expand Down

0 comments on commit a0e3f7d

Please sign in to comment.