For the big idea, see https://sive.rs/pg
I really took Rich Hickey's "Simplicity Matters" talk to heart. https://www.youtube.com/watch?v=rI8tNMsozo0
I've been making PostgreSQL-centered web apps for 9 years that way, by having PostgreSQL just return JSON. Then the "controller" (Ruby or whatever) parses the Mustache or ERB template with the JSON and returns HTML to the browser.
What I'm doing differently now is having PostgreSQL parse Mustache templates directly!
So now the controller just has to pass in the HTTP params, give it to the PostgreSQL function, and it returns HTML ready to return in the HTTP response.
Secondly, what do we do about things like HTML fragments à la HTMX / Datastar hypermedia approach? Do we just hit the DB for 10 lines of HTML to populate the next card in a multi step form?
Then I use this little Ruby script to sync them into the database, which is where they're actually used:
https://github.com/sivers/sivers/blob/master/scripts/templat...
I haven't done HTMX fragments yet. This repository is quite new, and only like 5% done.
Thanks for your response. I didn’t explain myself properly.
Suppose I have a html template that contains the dynamic value {{ foo }}, that template is on my SQLDB, how do I populate {{ foo }} whilst querying the template table?
I hope that makes more sense.
See it in practice here in the unit tests:
https://github.com/sivers/sivers/blob/master/omni/test/templ...
https://github.com/sivers/sivers/blob/master/omni/test/must_...
It comes from these three functions, but really only using the top-level "o.template" function:
https://github.com/sivers/sivers/blob/master/omni/template.s...
https://github.com/sivers/sivers/blob/master/omni/must_templ...
https://github.com/sivers/sivers/blob/master/omni/must_secti...
I'm using it for https://nownownow.com/ and https://my.nownownow.com/ already. Example test:
https://github.com/sivers/sivers/blob/master/nnn/test/mynow-...
It's not new, my first job circa 2007 was working on a Delphi 7 desktop application and all the "business logic" was stored procedures in an Oracle db. It was early in my career but I believe this was fairly popular in the early 00s. I was too young to have an opinion but for sure others will remember and be able to add more colour to it.
Nice seeing you around here! I'm a fan.
But PostgreSQL is not Oracle and doing things this way has been working wonderfully for me for 9 years so far.
So it makes sense to notice what's constant, what's ever-changing, and organize accordingly.
PS been a big fan of your writing over the years and it’s a little intimidating to just respond to one of your posts asking a silly question haha
He is a friend and much smarter than me. He told me to switch from MySQL to PostgreSQL. I'm so glad he did.
Some years down the road however this was changing. PostgreSQL began to catch up in terms of simple performance, but also MySQL stumbled on transitioning into a multicore world, while PostgreSQL scaled better due to some of the hard work already being done in the architecture. Additionally we got an included replication option, as well as all the main PaaS vendors providing automation around it. So MySQL's previous advantages became less compelling.
And today, hardware is so incredibly capable that just scaling vertically on a single server is totally viable for a ton of apps. For this swath of the market, just running PostgreSQL has become a bit of a no brainer in the way that MySQL was during the peak of LAMP.
I do a lot of meta link archiving and I wanted to create a link browser. My project supports data in zipped sqlite, or JSONs.
I believe data are as much important as programs, So everything is public.
Links
https://rumca-js.github.io/search - search (JSONs)
https://rumca-js.github.io/music - music (JSONs)
https://rumca-js.github.io/bookmarks - bookmarks (JSONs)
https://github.com/rumca-js/Internet-Places-Database - scripts use SQLite
https://github.com/rumca-js/web_link_browser - clean repo of scripts
Now I see the opposite. Web standards can solve the full reload page problem, so it's time to rethink if we still need to manage state in the client, with all the complexity that this involves.
The biggest issue for me it’s the division between backend and Frontend roles. I like to do both, but lately I’m doing backend. It changes a lot how we do things, refinements are mostly to create contracts between the Frontend and backend tasks, we’re they should focus on business use cases.
jppope•3h ago