tndrle / node-sqlite3-wasm

WebAssembly port of SQLite3 for Node.js with file system access
MIT License
55 stars 8 forks source link

Generator/iterator method #38

Closed flaviut closed 9 months ago

flaviut commented 9 months ago

It would be nice to have a .iterate() method that returns the rows one at a time, without loading the whole result set into memory.

For example,

for (const val of db.iterate("SELECT * FROM entries ORDER BY rowid")) { ... }
// OR
const stmt = db.prepare("SELECT * FROM entries ORDER BY rowid")
for (const val of stmt.iterate()) { ... }

Some example tests: https://github.com/WiseLibs/better-sqlite3/blob/ae23e690b02c00d075d543c66ae7e26c98c46f74/test/23.statement.iterate.js

tndrle commented 9 months ago

Thanks for the request. I'm working on it in #40. It won't be available in the Database class but in the Statement class.

tndrle commented 9 months ago

Implemented in #40

flaviut commented 9 months ago

Nice, thank you! This project has been super helpful in letting me work around idiosyncrasies with the AWS lambda environment. Really appreciate it.