WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.26k stars 391 forks source link

Support for AsyncGenerator in virtual tables #1072

Closed air2 closed 10 months ago

air2 commented 10 months ago

Hello,

Is it possible to support AsyncGenerators in virtual tables? This would mean the function: https://github.com/WiseLibs/better-sqlite3/blob/ae23e690b02c00d075d543c66ae7e26c98c46f74/lib/methods/table.js#L123 Would become async, or would get an normal and async implemntation

Prinzhorn commented 10 months ago

No https://github.com/WiseLibs/better-sqlite3/issues/319#issuecomment-549099116 (I don't think better-sqlite3 will ever have any async API parts)

But if you don't care about performance you might be able to hack async calls into the sync generator https://github.com/un-ts/synckit

Edit: I'd be curious about your specific use-case though

air2 commented 10 months ago

Yeah we are going to see if deasync work for us.

We are executing a query in a worker thread, and request some rows for a virtual table from the main thread, this communication is async, so we would prefer to use an AsyncGenerator for the rows property this obviously currently not supported. I could imagine more people who use virtual table, would want to generate the rows Async, but maybe it is a very unique use-case.