diff --git a/bindings/javascript/promise.js b/bindings/javascript/promise.js index cd8d4d702..e23c8ac9d 100644 --- a/bindings/javascript/promise.js +++ b/bindings/javascript/promise.js @@ -320,8 +320,23 @@ class Statement { * * @param bindParameters - The bind parameters for executing the statement. */ - *iterate(...bindParameters) { - throw new Error("not implemented"); + async *iterate(...bindParameters) { + this.stmt.reset(); + bindParams(this.stmt, bindParameters); + + while (true) { + const stepResult = this.stmt.step(); + if (stepResult === STEP_IO) { + await this.db.db.ioLoopAsync(); + continue; + } + if (stepResult === STEP_DONE) { + break; + } + if (stepResult === STEP_ROW) { + yield this.stmt.row(); + } + } } /** diff --git a/bindings/javascript/sync.js b/bindings/javascript/sync.js index a3bd934fc..759b8d729 100644 --- a/bindings/javascript/sync.js +++ b/bindings/javascript/sync.js @@ -319,7 +319,22 @@ class Statement { * @param bindParameters - The bind parameters for executing the statement. */ *iterate(...bindParameters) { - throw new Error("not implemented"); + this.stmt.reset(); + bindParams(this.stmt, bindParameters); + + while (true) { + const stepResult = this.stmt.step(); + if (stepResult === STEP_IO) { + this.db.db.ioLoopSync(); + continue; + } + if (stepResult === STEP_DONE) { + break; + } + if (stepResult === STEP_ROW) { + yield this.stmt.row(); + } + } } /**