tursodatabase / tursodatabase/libsql-js

Support for Closing Statement Iterator

Open
#139 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
335
Forks
48
Avg merge
3d 2h
Merged PRs (30d)
3

Description

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!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the implementation of stmt.iterate() and the iterator methods used by iter.next() in the JavaScript API. Trace how iteration cleanup currently works, then verify that iter.return() stops further reads and performs the same cleanup as manually exhausting the iterator.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, sqlite
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.