Re:Building single-page-apps with PostgREST
by agentultra on Sunday January 30, 2022 @10:29AM
(#30137966)
I wrote postgresql-replicant [0] in order to do this. Itβs not a novel idea. It lets you read the logical replication stream.
On top of this library you can do all sorts of things: replicate data to Kafka or SQS, write a web socket server to publish changes to clients, etc.
Re:Building single-page-apps with PostgREST
by piaste on Sunday January 30, 2022 @06:56AM
(#30136273)
> Next you need push and pub/sub semantics in PostgreSQL
It's fairly basic (then again, does it need to be more?), but NOTIFY exists: https://www.postgresql.org/docs/current/sql-notify.html
If you considered PostgreSQL as a cloud platform it has some useful properties. A well understood API that is consistent across different products. Built in authorisation and authentication. Reliable data storage without having to think to much about the underlying hardware. Triggers that allow activity in one product to initiate a process in another. Support for running sandboxed code in several languages without needing a "server". And you even have some benefits. Your entire infrastructure can be dumped to a file. The infrastructure can be altered in a transaction that can be rolled back. And external services can be integrated as first class citizens (more or less).
Re:Building single-page-apps with PostgREST
by merarischroeder on Tuesday February 01, 2022 @05:00PM
(#30170069)
That's interesting - have a look at https://colossal.gitbook.io/microprocess/a-totally-new-conce...
All you need to do is map JWT to a Phantom DB User in PostgreSQL, then you can query SQL directly from the browser.
Re:Building single-page-apps with PostgREST
by nileshtrivedi on Saturday January 29, 2022 @10:34PM
(#30133672)
"Reversible SQL" is such a great idea. PostgreSQL does have pub/sub semantics via LISTEN and NOTIFY. At some level, we should think about removing the centralized database completely, and let all of user's devices synchronize with each other somehow. Perhaps SQLite database files synchronized with syncthing? That would really be fantastic!
Re:Building single-page-apps with PostgREST
by CuriouslyC on Sunday January 30, 2022 @12:11AM
(#30134249)
CouchDB has a javascript client called PouchDB that can do multi-"master" replication and streaming. I wouldn't use it as a primary database, but the syncing story is pretty much top notch.
Postgres has logical replication[0], which the Supabase client uses for real-time data subscriptions.
[0]: https://www.postgresql.org/docs/10/logical-replication.html
The share of discourse on HN about PostgreSQL, SQL, and Databases is growing noticeably. [0] I, for one, hope we are seeing the pendulum swing back from code-centric architectures and NoSQL to a new golden age of data-centric architectures.
Next you need push and pub/sub semantics in PostgreSQL so you can build something like this [1]
[0] https://toddwschneider.com/dashboards/hacker-news-trends/?q=... [1] https://tonsky.me/blog/the-web-after-tomorrow/