You are not logged in.
Pages: 1
Hi, there!
ME and my colleagues are looking for a sample using MVC using mORMot framework. We´ve stumbled upon example 30, but there we have coupled persistence logic to the controller which is not compatible with MVC separation of concerns. Could anyone help us providing a sample respecting MVC SoC? Many thanks in advance.
Regards,
Geovanny Ribeiro
A humble guy passionate about his family and technology!
Offline
Hi, Arnaud!
That´s exactly we were talking about yesterday at the office! By the way, we were thinking about database transactions as well. Maybe we could use a service layer to start transactions when multiple persistence operations are needed. What would you suggest? Two layers: service & repository? Actually we still in doubt about one thing: in example 30 MVC we have the Blog controller inheriting from TMVCApplication which clearly contains persistence logic (through RestModel class) if we create a repository inheriting from TMVCApplication this repository would be accessible through web as well (this would be an undesirable side effect)? Many thanks for your promptly reply. Good. day!
A humble guy passionate about his family and technology!
Offline
Transactions have to be done explictly at service level.
Using a two-phase commit, e.g. as defined with the Persistence service (Commit/Rollback) as defined in the User Persistence DDD units, and detailed in the doc. RTFM may help.
The persistence logic in sample 30 is defined in the MVCModel.pas unit.
It is clearly uncoupled from the main MVCViewModel.pas unit.
The ORM methods are called directly, and hosted in the main RestMode: TSQLRestServer instance, but it definitively does make sense, in this case.
Anyway, you should NOT inherit your repository from TMVCApplication.
It does not make sense. This would be even worse than the current implementation.
The repository IS a service.
Define an interface, injected in TMVCApplication as a separated persistence class.
You may define the repository service in the Model unit, together with ORM classes - for the sample 30, the repository service may have been defined in MVCModel.pas unit.
Offline
Hi, Arnaud!
Thanks again for your promptly reply. Don´t get me wrong based on my questions that´s because I´m acting as a translator for the Delphi dev team at my office. I´m a Java dev not a Delphi one, ok? The guys asked me to question you about how they can customize the http routes because the basic ones are based on models, but if you need to create custom routes? Regards.
A humble guy passionate about his family and technology!
Offline
Pages: 1