#1 2017-10-30 03:23:40

ianc
Member
Registered: 2017-01-12
Posts: 17

SOA question

Hi All
I am working through the mormot framework samples
I have had success with CRUD and the method based servers with client database interaction
I have moved on to SOA and am able to Add and Insert into my database
I wondered if there was an example of navigating in the database using interfaces i.e. go to first or last record
I read that these verbs are not available with SOA but there must be a requirement to navigate databases tables
I am using Delphi Berlin 1.0 starter edition
My problem is navigating back to the record i have just added so to edit it

Any advice will be appreciated by this Newbie

smile

Offline

#2 2017-10-30 07:04:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,240
Website

Re: SOA question

As you stated in your question, you are still pretty close to a DB-first approach.
Since your TDataSet is able to "navigate" via First/Next/Last methods, you are used to implement this pattern.
But is it really what your user expect?
Idea with SOA is not to reproduce exactly how a RAD project looks like.

In the SOA context, you need to implement a "Repository" service.
This is an object-first persistence service.
There is plenty of litterature about how to write such a persistence service.
See e.g. https://martinfowler.com/eaaCatalog/repository.html
https://martinfowler.com/bliki/PolyglotPersistence.html
https://www.martinfowler.com/bliki/Anem … Model.html

The main pattern is not to have an "anemic domain", so not an "anemic repository" either, which may be just a CRUD-like access to the DB.
You should better not just have Add/Get/Update/Delete methods on whole aggregate objects, but write something more tuned.
A rich Repository service consist in a context-oriented interface definition: you define input and output values for each method depending on the particular purpose.
For instance,  instead of plain "AddPeople", you define a "RegisterNewUser" persistence method. This method may return the newly created object, or at least its newly created ID (not defined as plain DB ID, but as a genuine identifier matching the domain naming). Then you will be able to navigate back to the just added record.

In the mORMot context, ensure you looked at https://tamingthemormot.wordpress.com/
especially https://tamingthemormot.wordpress.com/2 … databases/

Offline

#3 2017-10-31 06:47:37

ianc
Member
Registered: 2017-01-12
Posts: 17

Re: SOA question

Hi AB

Thanks for the positive response. Made good progress today and excited about the future. Its a change of mind set.
IC

Offline

Board footer

Powered by FluxBB