|
|
|
|
|
by ahpearce
2140 days ago
|
|
That is not always a great idea. There is a reason APIs exist, and backend service layers exist on top of databases. It is a larger abstraction of the interface design pattern. It only makes sense if you're absolutely sure you'll never need to extend or change the interaction between front-end and back-end. Think just about schema migrations on the database. If you change your schema, you have to change your front-end. Maybe that's okay for the time, but that can get out of hand pretty quickly. On the other hand, with a service layer, you could completely decouple that dependency on the front-end, by providing the front-end an interface (the service layer / API). The migrations on the database layer don't affect the front-end whatsoever, because the front-end communicates with the interface. You can change the underlying implementation without changing the front-end's interaction with the interface. http://best-practice-software-engineering.ifs.tuwien.ac.at/p... |
|
With views you can maintain backwards compatibility despite migrations happening. No need to change your front-end.
Check this section of the PostgREST docs for more details:
http://postgrest.org/en/v7.0.0/schema_structure.html#schema-...