tursodatabase / libsql-client-ts

TypeScript/JavaScript client API for libSQL
https://docs.turso.tech/sdk/ts/quickstart
MIT License
182 stars 30 forks source link

Switch to Node's filesystem for libsql-wasm #175

Open penberg opened 4 months ago

penberg commented 4 months ago

Suggested by Dominic Elm.

d3lm commented 4 months ago

Hey 👋 Thanks for creating this ticket. The reason I suggested to use the Node.js file system is because the db file would be persisted across reloads as it could be written to the host file system (the host here is WebContainer). AFAIK libsql was compiled via Emscripten so instead of using an in-memory file system there could be a version that uses Node's raw file system via NODERAWFS. This means nothing has to be mounted and it would directly use the Node FS.

d3lm commented 4 months ago

Or potentially, if this is meant to be used via Node.js always then maybe we can make it the default and if we wanted a browser version then we could publish a separate *-web package maybe.

penberg commented 4 months ago

I looked into this with @d3lm and we likely want a VFS implementation that uses Node filesystem API that we can plug into the SQLite/libSQL Wasm build.

penberg commented 4 months ago

Here's one implementation of the VFS approach for upstream SQLite: https://github.com/tndrle/node-sqlite3-wasm

rphlmr commented 2 months ago

I am working on "Drizzle play" that relies on WebContainer. It would definitely help to have this feature!