3 ms·
Whoa. How weird to see this on the HN front page. It's so not ready yet. I'll write up more about it some day soon. For the big idea, see https://sive.rs/pg ht
by sivers 1y ago
Whoa. How weird to see this on the HN front page. It's so not ready yet. I'll write up more about it some day soon.
For the big idea, see https://sive.rs/pg https://sive.rs/pg
I really took Rich Hickey's "Simplicity Matters" talk to heart. https://www.youtube.com/watch?v=rI8tNMsozo0 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.
- danielcberman 1y agoHave you crossed paths with Chris Dancy? He’s been doing something similar with a life database using Airtable. https://www.chrisdancy.com/howto https://www.chrisdancy.com/howto
- chrisweekly 1y agoGreat link, Chris Dancy's experiences and relationship to tech are very interesting.
- hatefulheart 1y agoDespite reading the README and the article I am still unclear about how these templated values are populated. So presumably we store our HTML on the sql server along with some templating syntax then how do we plug that value so to speak? 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?
- sivers 1y agoI edit my HTML templates in the templates/ directory. 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/template-sync.rb 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.
- hatefulheart 1y agoHey, 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.
- sivers 1y agoAh, sorry. I misunderstood. The parser for Mustache templates - https://mustache.github.io/ https://mustache.github.io/ - is in the PostgreSQL functions. See it in practice here in the unit tests: https://github.com/sivers/sivers/blob/master/omni/test/template.sql https://github.com/sivers/sivers/blob/master/omni/test/templ... https://github.com/sivers/sivers/blob/master/omni/test/must_template.sql 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.sql https://github.com/sivers/sivers/blob/master/omni/template.s... https://github.com/sivers/sivers/blob/master/omni/must_template.sql https://github.com/sivers/sivers/blob/master/omni/must_templ... https://github.com/sivers/sivers/blob/master/omni/must_sections.sql https://github.com/sivers/sivers/blob/master/omni/must_secti... I'm using it for https://nownownow.com/ https://nownownow.com/ and https://my.nownownow.com/ https://my.nownownow.com/ already. Example test: https://github.com/sivers/sivers/blob/master/nnn/test/mynow-welcome.sql https://github.com/sivers/sivers/blob/master/nnn/test/mynow-...
- hatefulheart 1y agoThank you very much!
- jdmoreira 1y agoHi Derek! 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.
- sivers 1y agoThanks! I do often get "YOU IDIOT!" type comments from people that did too many Oracle stored procedures in the 90s, and were burned by it. But PostgreSQL is not Oracle and doing things this way has been working wonderfully for me for 9 years so far.
- ako 1y agoOracle has a nice way to bundle stores procedures in packages, which makes large amounts of stored procedures manageable. So still ahead of Postgres, but Postgres is definitely good enough.
- sirtaj 1y agoAsking from ignorance - are schemas not enough to replicate this most of the way? What are the extra nice to haves that would bring PG on par with Oracle here?
- ako 1y agoWith packages you can group stored procedures, stored functions, types and variables in logical bundles. Easier to install and understand.
- whizzter 1y agoI haven't had the "pleasure" to work with stored procedures,etc but from conversations the main takeaways seems to be: 1: cooperation, nowadays database instances are cheaper and with Docker we can spin them up but having them shared doesn't feel like a fun thing when developing (triggers more than stored procedures here) 2: version control, kinda ties to the above but being able to keep track of changes (and related then to code being out of sync even if that would matter less in a application-less world) 3: debugging in general ? 4: debuging "spooky effects at a distance" when triggers,etc run. What's your take on these?
- arunaugustine 11mo agoFor someone who wants to tread this path, using postgreSQL stored procedures in a team settings, what would be a good dev workflow in a team. Update them in git and use a CI to update the DB etc? Is there some tips that you can share on that?