tinybase
tinybase copied to clipboard
Persists Tinybase to Turso's SQLite Edge
I am trying few options to use tinybase in my local-first application I was wondering will it be possible to sync the local SQLite DB from the client (Browser) from wa-sqlite to Edge database prodvider like Turso . Turso encourages to create separate database for each users, mixing tinybase's localfirst approach will be a great user experience
If this is as simple as hooking into LibSQL, I think this can be done easily enough. Am I missing an extra step?
Main question seems to be whether to integrate with (newer) libsql-js or (older) libsql-client, or both
hello @jamesgpearce - founder of Turso here. Great to see Turso integrated into this project!
the libsql-js
driver is a dependency of @libsql/client
, and is lower level. If you need to go down to a lower level, you may have to use it, but if possible, integrate with @libsql/client
.
Thanks for swinging by! And thanks for the clarification. I'll take a look.
@glommer I'm wondering if there's a way to subscribe to database changes. My other sqlite-based adapters all provide a way to get to sqlite3_update_hook
which I can listen to. I can't see that exposed in either libsql-js or libsql/client. Am I blind? :)
If not, is there another way to subscribe to changes, other than polling?
Please give v4.7.0 a whirl! I use polling for now. https://tinybase.org/
hey @jamesgpearce how did you do the integration? If you integrated at the level of our C api, this function should still be there. If you integrated at the typescript client SDK, indeed I think there's no typescript API that exposes that directly. Can you point us to how you are doing this with any other adaptor? We're happy to expose a similar function.
Tagging my cofounder @penberg in this thread!
At the moment I am polling which is not ideal but it works. If you can expose that hook that would be awesome though. Eg Expo SQLite has addDatabaseChangeListener
, CR-SQLite has onUpdate
, sqlite3 has db.on('change'...
etc etc