Hello,
Preamble
I've searched around in support and found that Aurelius is not handling (so far) default values.
I mean, if the (mysql) database structure is this:
CREATE TABLE `com_plants` (
:
`isActive` tinyint(1) DEFAULT 1 ,
:
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Plants';
the auto-generated entity is
[Entity]
[Table('com_plants')]
TctsCOM_plant = class
private
:
[Column('isActive', [])]
FisActive: Nullable<Integer>;
:
public
constructor Create;
:
property isActive: Nullable<Integer> read FisActive write FisActive;
:
end;
My solution at present for default values is to set them in costructor
constructor TctsCOM_plant.Create;
begin
// set default values (Aurelius missing...)
FisActive := 1;
end;
Now the real topic question
Since I'm having an admin portal where user can browse records with grids and create new lines (new records) I need to start with default values pre-setup in editing forms whenever a new record is created and before it is posted.
I'm using Aurelius CRUD Endpoints and have set the XDataServer.RoutingPrecedence to Service in order to use XData services with same path (a kind of "aside" path).
So far I've written a service with path "/new" in order to get the default values
[HttpGet]
[Route('/new')]
function getNewRecord: TctsCOM_plant;
// implementation
function TctsComPlantsService.getNewRecord: TctsCOM_plant;
var
NewPlant: TctsCOM_plant;
begin
NewPlant := TctsCOM_plant.Create;
Result := NewPlant;
end;
and pass them to the edit form.
Now, since I have LOTS of entities... is there an (easy) way to add a common path to Aurelius CRUD endpoints and avoiding writing lots of services with a single additional endpoint?
Quite a long post... I hope that all above is clear - thanks in advance!