@bdkinc/knex-ibmi 0.3.3 → 0.3.6
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 +1 -1
- package/dist/index.js +19 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -208,7 +208,7 @@ try {
|
|
|
208
208
|
|
|
209
209
|
await finished(data); // db queries are promises, we need to wait until resolved
|
|
210
210
|
|
|
211
|
-
// or we can iterate through each record
|
|
211
|
+
// or we can iterate through each record
|
|
212
212
|
for await (const record of data) {
|
|
213
213
|
console.log(record);
|
|
214
214
|
}
|
package/dist/index.js
CHANGED
|
@@ -449,7 +449,7 @@ var DB2Client = class extends import_knex.knex.Client {
|
|
|
449
449
|
this.printDebug(obj);
|
|
450
450
|
return obj;
|
|
451
451
|
}
|
|
452
|
-
_stream(connection, obj, stream, options) {
|
|
452
|
+
async _stream(connection, obj, stream, options) {
|
|
453
453
|
if (!obj.sql) throw new Error("A query is required to stream results");
|
|
454
454
|
return new Promise(async (resolve, reject) => {
|
|
455
455
|
stream.on("error", reject);
|
|
@@ -460,13 +460,24 @@ var DB2Client = class extends import_knex.knex.Client {
|
|
|
460
460
|
});
|
|
461
461
|
const readableStream = new import_node_stream.Readable({
|
|
462
462
|
objectMode: true,
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
463
|
+
read() {
|
|
464
|
+
cursor.fetch((error, result) => {
|
|
465
|
+
if (error) {
|
|
466
|
+
console.log(error);
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (!cursor.noData) {
|
|
470
|
+
this.push(result);
|
|
471
|
+
} else {
|
|
472
|
+
this.push(null);
|
|
473
|
+
cursor.close((error2) => {
|
|
474
|
+
if (error2) {
|
|
475
|
+
console.log(error2);
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
});
|
|
470
481
|
}
|
|
471
482
|
});
|
|
472
483
|
readableStream.on("error", (err) => {
|