News for hackers. Stuff that matters.
Re:PostgREST: REST API for any Postgres database by systemvoltage on Saturday November 21, 2020 @02:20PM (#25172026)
> Which is, you'll notice, the same best practice used for decades by DBAs who need to serve multiple applications connecting to the same database.

Clearly, the Database's job contrary to what the name suggests is to not only stick data into it but also a bunch of business logic that's essentially untestable. No one needs domain models when you've got database tightly coupled with behavior and logic of your business.

What could go wrong?

The whole point of the API is that it is a repository for accessing the data from one or more databases, and packaging it up for the user to consume. It imports domain models which are totally isolated from the rest of the dependencies. The data doesn't even have to be in the database and can come from multiple sources such as S3 or whatever. It can consume data from the user and kick off various processes or insert into the database. It is a generic interface that does more than just CRUD in the DB.

Re:PostgREST: REST API for any Postgres database by mojzu on Saturday November 21, 2020 @02:33PM (#25172163)
You can use pgTAP for postgres unit testing, with docker you can make the process pretty fast too. Id highly recommend looking into the features/extensions of postgres, there's a lot of great stuff that goes beyond just being a database which can save a lot of time and grief depending on the application.

There is a risk of mixing storage/business logic, and you might end up being tied to postgres, but it's manageable using functions/views/schemas. And its also a really convenient place to do some business logic, as all your data is right there and available via a very expressive/extensible query language.

Re:PostgREST: REST API for any Postgres database by piaste on Saturday November 21, 2020 @05:05PM (#25173084)
If your API needs to serve data that lives in multiple sources, then PostgREST is definitely not the right tool.

It is, however, a pretty common design to have all your data flowing into a database, and being served from there. Indeed, it's probably the simplest and most common design for a basic web application. PostgREST or Hasura can do excellent work there.