I am wondering if the upcoming support of SQLDelig...
# squarelibraries
m
I am wondering if the upcoming support of SQLDelight/SQLite for the wasmJs platform will be able to cover the following use case. We currently have an app which downloads a whole sqlite database file from the internet via Kator, stores it locally and then opens and works with this database via SQLDelight. This approach was chosen, so that when you have an internet connection you have to download just a single file and after that you can work offline and can be sure to have all the data locally that you will ever need. Where would this database have to be stored so that it can be used directly by SQLDelight?
d
I would look at using the Origin-Private File System APIs to store the file and seeing if that can be loaded directly through SQLite Wasm SQLDelight doesn't include a worker implementaiton that uses SQLite Wasm (yet), but you can supply your own web worker to use with the SQLDelight web worker driver (e.g. like this)
m
Thanks. That looks interesting. I tried your demo at https://dellisd.github.io/sqldelight-sqlite-wasm but it doesn’t seem to work. I only got a
Copy code
"G: {\"message\":\"sqlite result code 1: no such vfs: opfs\",\"name\":\"Error\"}\n    at R.tx (<https://dellisd.github.io/sqldelight-sqlite-wasm/sqldelight-sqlite-wasm.js:1:315503>)\n    at R.handleEvent (<https://dellisd.github.io/sqldelight-sqlite-wasm/sqldelight-sqlite-wasm.js:1:315653>)"
d
OPFS needs some specific headers in order to be enabled which can't be controlled on github pages, so I don't think the live demo ever worked
but if you build and run locally I think it should still work
m
Does that mean that I run the risk that the same might happen to my own app if I try to run it via a hosting provider where I also don’t have full control over all these magic headers? I slowly start to realize that the web is a very limited platform full of surprises. 🤨
1
d
Yeah, that could be an issue
🙏 1