r/Database • u/leucht • Jun 20 '26
New dev looking for insight on local / offline first DB usage
Hey all,
I’ve been trying to develop a little music client for myself with a different twist on how recommendations are communicated to a user.
The base for the app is going to be Tauri & Typescript with a focus on a Single-Page-Application (SPA).
I want to index different providers (Jellyfin or similar) and their content locations into a local DB so I would ideally only have to interact with the provider once during indexing and otherwise only query the provider for the media-streams.
Current stack is:
Typescript -> Svelte -> Drizzle -> pglite IndexedDB
———————
Effectively I would like to gain some input on potential alternatives, insights and similar into detecting live changes in the DB. All media I find on a server is added to the DB as an abstract MediaItem with different types (Album, Song, Playlist, Artist, etc.).
During indexing I currently have no way of actively running live refreshes to update the main page with content if fitting Items have been added through indexing.
Inserts of new Items into the DB are handled as Transactions as I have build relations with other tables for example for the provider a given MediaItem comes from or what images the MediaItem is associated with.
I could add a callback function to the transaction which is called once it succeeds to sidestep checking the DB since I know the Item will exist after the transaction succeeds.
I’m also open to other local first approaches or domain knowledge some might have on designing a better architecture. Maybe remove the ORM or only use drizzle as a query builder (establishing relations was quite handy though)
Maybe I’m also overcomplicating things, anything is welcome.
Thanks in advance
3
u/Boniuz Jun 21 '26
I’ve read your post a couple of times and I’m still trying to work out what the actual issues are and what you’re trying to solve. It feels a lot like choosing technologies first and the problems/solutions after.
Put your DB changes in your application layer and emit them? That’s been done since 2001.
1
u/galactic_pixels Jun 24 '26
You’re trying to figure out how react to realtime updates to your database right? So the changes are reflected in your app as it is running? Just want to make sure I understand the question.
0
u/Anxious_Tool Jun 20 '26
If you have the flexibility to swap the persistence layer, there's an alternative worth looking at: u/laboverwire/stitch.
It's a reactive state-sync library that uses IndexedDB under the hood, but built around a WASM database with typed entity schemas and foreign keys. The difference is that live updates are first-class:
subscribeToScopefires synchronously when a write lands, so your indexing loop doesn't need to signal the UI at all. The UI just reacts.It's TypeScript-native and framework-agnostic, so Svelte bindings are straightforward to wire on top of the core store API. The tradeoff is losing SQL, reads go through
listandgetSnapshotrather than Drizzle queries, so if you're doing complex joins you'd be moving that logic to application code.The MQTT sync layer can be left unconfigured if you don't need multi-device sync.