@bdkinc/knex-ibmi 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -156,6 +156,8 @@ try {
156
156
  ```typescript
157
157
  import { knex } from "knex";
158
158
  import { DB2Dialect, DB2Config } from "@bdkinc/knex-ibmi";
159
+ import { Transform } from "node:stream";
160
+ import { finished } from "node:stream/promises";
159
161
 
160
162
  const config: DB2Config = {
161
163
  client: DB2Dialect,
@@ -186,8 +188,28 @@ try {
186
188
  .from("table")
187
189
  .stream({ fetchSize: 1 }); // optional, fetchSize defaults to 1
188
190
 
191
+ // use an objectMode transformer
192
+ const transform = new Transform({
193
+ objectMode: true,
194
+ transform(
195
+ chunk: any,
196
+ encoding: BufferEncoding,
197
+ callback: TransformCallback,
198
+ ) {
199
+ // chunk will be an array of objects
200
+ // the length of the array is the chunk size
201
+ console.log(chunk);
202
+ callback(null, chunk);
203
+ },
204
+ });
205
+
206
+ // pipe through the transformer
207
+ data.pipe(transform);
208
+
209
+ await finished(data); // db queries are promises, we need to wait until resolved
210
+
211
+ // or we can iterate through each record one at a time (fetchSize has no effect)
189
212
  for await (const record of data) {
190
- // returns an array of objects, length of array is determined by fetchSize
191
213
  console.log(record);
192
214
  }
193
215
  } catch (err) {
package/dist/index.d.ts CHANGED
@@ -61,7 +61,6 @@ declare class DB2Client extends knex.Client {
61
61
  _query(connection: any, obj: any): Promise<any>;
62
62
  _stream(connection: any, obj: any, stream: any, options: {
63
63
  fetchSize?: number;
64
- initialBufferSize?: number;
65
64
  }): Promise<unknown>;
66
65
  transaction(container: any, config: any, outerTx: any): Knex.Transaction;
67
66
  schemaCompiler(tableBuilder: any): IBMiSchemaCompiler;
package/dist/index.js CHANGED
@@ -464,8 +464,7 @@ var DB2Client = class extends import_knex.knex.Client {
464
464
  async read() {
465
465
  const cursor = await connection.query(obj.sql, obj.bindings, {
466
466
  cursor: true,
467
- fetchSize: options?.fetchSize || 1,
468
- ...options
467
+ fetchSize: options?.fetchSize || 1
469
468
  });
470
469
  while (!cursor.noData) {
471
470
  const result = await cursor.fetch();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bdkinc/knex-ibmi",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Knex dialect for IBMi",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",