libsql-js
libsql-js copied to clipboard
Support for Closing Statement Iterator
Currently, better-sqlite3 allows stopping an active iterator by calling return(). This ensures clean-up and halts further reads. Here's an example:
const stmt = db.prepare("SELECT * FROM organizations"); // This has 100k rows
const iter = stmt.iterate();
const row = iter.next();
if (cancelTriggered) {
iter.return(); // Stop reading and perform clean-up
}
Since we don't yet support return(), an alternative is to manually exhaust the iterator:
if (cancelTriggered) {
for (const _row of iter) {}
}
Would it be possible to add support for return() to simplify the process? Thanks!