deno-sqlite
deno-sqlite copied to clipboard
OPFS support
It'd be interesting if the browser version of this package used the origin-private file-system APIs rather than IndexedDB. I think that's become kinda the "official" way to run sqlite in the browser nowadays.
OPFS beats IndexedDB in in raw I/O performance and having a mostly synchronous API, but there are still quite a few reasons a particular application might prefer IndexedDB:
- OPFS access handles don't work in a SharedWorker.
- OPFS access handles don't work in a service worker.
- OPFS access handles don't work in a browser extension.
- IndexedDB has better browser support.
- IndexedDB can allow trading durability for performance.
- IndexedDB can be much faster with small write transactions (though slower at almost everything else).
I don't think it makes sense to say that either OPFS or IndexedDB is the only way to implement SQLite storage. And if you're only going to do one, I think for a library targeting lots of different applications there's a reasonable argument that IndexedDB's greater flexibility can outweigh OPFS's mostly performance-related benefits.
We could support both relatively easily (assuming we make a VFS that supports OPFS). The current browser support uses an import map to replace the VFS so it’s quite easy to swap in another one!