News for hackers. Stuff that matters.
Re:Building single-page-apps with PostgREST by andrenotgiant on Saturday January 29, 2022 @10:16PM (#30133538)
This is kind of crazy but really interesting as a sort of extreme manifestation of data-centric applications. I say it's crazy, but startups like Supabase are essentially building the professional version of your idea.

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/

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.

[0] https://github.com/agentultra/postgresql-replicant

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

Re:Building single-page-apps with PostgREST by 7952 on Sunday January 30, 2022 @05:30AM (#30135638)
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.
Re:Building single-page-apps with PostgREST by ovao on Sunday January 30, 2022 @12:41AM (#30134418)
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

Re:Building single-page-apps with PostgREST by cpursley on Sunday January 30, 2022 @05:56AM (#30135789)
Yep, I actually pulled out the Supabase realtime code into an individual library so that you can listen to Postgres changes right in Elixir:

https://github.com/cpursley/walex