You are not logged in.
Pages: 1
Hi All,
Just joined the forum and am determined to get going with MORMOT, but the learning curve is daunting despite looking at the docs and taming the mormot.
Using both Lazarus 1.8 and Delphi 10.2.1 but working to get off Delphi at the crazy cost it is
Need to set up a class, a model and a server saving to a firebird database i.e an ORM. Having trouble even with looking at the sample projects getting this coded.
Can someone give links to / code for simple basic implementation of this
My class is
TSQLPatient = class(TSQLRecord)
// NB: All classes for the ORM have to be named beginning with TSQL This was not clear at first
private
F_UR: Integer;
F_Name: RawUTF8;
F_DOB: TTimeLog;
F_Addr1: RawUTF8;
published
Property UR: Integer read F_UR write F_UR;
Property Name: RawUTF8 read F_Name write F_Name;
Property DOB: TTimeLog read F_DOB write F_DOB;
Property Addr1: RawUTF8 read F_Addr1 write F_Addr1;
end;
Need to then create a TSQLModel and TSQLRestServer
TForm1.Button1Click(Sender: TObject);
var
R: TSQLPatient;
M: TSQLModel;
Server: TSQLRESTServerDB;
begin;
M := TSQLModel.create([TSQLPatient]); // The [] are an array of tables, in this case with just one table
If M.AddTable(TSQLRecordClass(TSQLPatient)) = false then beep;
Server := TSQLRESTServerDB.Create(M);
ADBCon := TSQLDBConnectionProperties.Create('','c:\mg\mgsoftware\Mormot\Dbase\Test.fdb','SYSDBA','masterkey');
Server.createmissingtables;
R := TSQLPatient.Create;
R.Name := 'UR';
R.UR := 1;
R.DOB := TimeLogFromDateTime(Now);
R.Addr1 := '123 Any Street';
// So how to add a record to the model, to the server and then to the database?
FreeAndNil(M);
FreeAndNil(R);
FreeAndNil(Server);
end;
Any help appreciated. I'll get there..
Martin
Offline
Welcome, and thanks for your interest!
Please don't write such extensive code in the forum itself.
Check again the forum rules: https://synopse.info/forum/misc.php?action=rules
Please post it, as a running example, in an external store.
Your code is not correct, since it didn't make any connection with Server and ADBCon, via the Model.
You need to call https://synopse.info/files/html/api-1.1 … ALREGISTER
Read again the doc about external databases, and start from existing working examples.
https://synopse.info/files/html/Synopse … l#TITL_145
I also took the liberty to delete your other post, which sounded like a duplicate.
Offline
Hi
OK so need to add
VirtualTableExternalRegister(M,TSQLRecordClass(R),ADBCon,'Pt_Info'); // links model to external database
and do this before the server is created.
Will read more of the documentation and examples. Will persevere as the framework offers what I need but there is much to learn first.
I am in Melbourne, Australia. Wondering if any mORMot users are here and could form a local users group?
Thx
Offline
Pages: 1