News for hackers. Stuff that matters.
Re:Stop building databases by matlin on Friday December 01, 2023 @12:56PM (#38489850)
I'm currently writing a very similar article about "full-stack databases" which highlights the same pattern where many apps end recreating the logic of our backend and database in the frontend client code. The solution we're promoting is to choose a database that can run on both the server and in the client and then sync between them.

The reason we aren't using Sqlite for our product is because Sql is frankly not the right tool for querying data for an application. It doesn't easily map to the data-structures you want in your client code and nearly all SQL databases have no way to subscribe to changes to a query without polling the query repeatedly.

So if you like the idea of having a complete database on your client but also want deep integration with Typescript/Javascript check out what we're building at https://github.com/aspen-cloud/triplit

Re:Stop building databases by culi on Friday December 01, 2023 @02:35PM (#38491157)
I like the implications of this to a "local first" architecture
Re:Stop building databases by johnny22 on Friday December 01, 2023 @01:01PM (#38489936)
postgres has some capability to do that, but does need a server.
Re:Stop building databases by matlin on Friday December 01, 2023 @01:12PM (#38490101)
Yeah you can subscribe to overall changes to the data on a row by row basis but can't subscribe to an actual query. Many apps and libraries imitate reactive queries by just refetching all queries from Postgres when any data changes or just repeatedly polling the query every 10 seconds or so but this puts a lot of strain on the database. You can just subscribe to the replication stream but then you're left trying to reconstruct your queries in your application code which is extremely error prone and painful
Re:Stop building databases by cpursley on Saturday December 02, 2023 @03:19AM (#38496959)
Could you explain in more detail the use case for subscribing to the actual queries (instead of the change events)?
Re:Stop building databases by qudat on Friday December 01, 2023 @10:16PM (#38495553)
> It doesn't easily map to the data-structures you want in your client code

I disagree. Normalizing data is critical for FE reactive applications, keeping data up-to-date basically requires it; all CRUD operations are much easier to handle.

Re:Stop building databases by Hithredin on Saturday December 02, 2023 @01:03AM (#38496341)
Realm Sync, Mongo + Kotlin MP will cover basically all platforms (server, web, mobile, desktop)... at a cost. Actually interested by alternatives. Will this be part of your article?
Re:Stop building databases by matharmin on Saturday December 02, 2023 @01:08AM (#38496367)
SQLite does actually provide the mechanisms required to listen for changes via update hooks. It's unfortunate that many SQLite bindings don't expose that. I'm using it in a very simple way - automatically rerun the query if data in the underlying table changes. It's perhaps not as efficient as incrementally updating the results, but with how fast queries in SQLite usually are, I find that doesn't really matter.
Re:Stop building databases by cpursley on Saturday December 02, 2023 @03:16AM (#38496939)
Actually, Postgres provides a great way to subscribe to real time changes via the WAL. I even maintain an open source library for this:

https://github.com/cpursley/walex