News for hackers. Stuff that matters.
Re:Show HN: Rust Web Framework by cies on Wednesday October 23, 2024 @06:14AM (#41923559)
Exactly how we do services.

We have one model file per db table (a "repository") in which we define all queries that "logically belong to that table" (sure they do joins and/or sub-queries that involve other tables, but they still "logically belong to a specific table").

Once we need logic that combines queries from several "repositories", we put that in a "service" file that's named after what it does (e.g. PriceCalculator).

Most of our business logic is in the models (repositories and services), other encapsulated in the SQL queries. Repositories never call services. Model code never calls controller code. Pretty happy with it.

Re:Show HN: Rust Web Framework by tcfhgj on Wednesday October 23, 2024 @08:27PM (#41930662)
When you join two tables, which model does the query belong to?
Re:Show HN: Rust Web Framework by cies on Thursday October 24, 2024 @04:13AM (#41933269)
We'd not call it a model, we have no notion of "a model", merely a package called "models" (in line with MVC separation).

We do have repositories. And when joining it could belong to both tables, and thus to both repositories. In those cases the devs picks one: the one that it most prominent to him.