You are not logged in.
Hello,
I build a server (interface based). For testing, i'm using this class:
TSQLBiolife = class(TSQLRecord)
private
...
fCommon_Name: RawUTF8;
fSpecies_Name: RawUTF8;
...
fNotes: TSQLRawBlob;
published
....
end;
Now I'm trying to achieve CRUD over AJAX.
My main objective is to exchange JSON between Client and Server and to mimic as much as possible the TclientDataset.Delta behavior.
I spent time reading the documentation and some presentation (FROM SQl to ORM ...).
I saw many functions about serialization but don't know how to do.
I check also the examples. I found only one (Samples\ThirdPartyDemos\Migajek\synopse-sqlite-demo) where we are building a list after CreateAndFillPrepare. Not JSON list and maybe not relevant, I don't know...
For example about reading Data (I would like to retrieve many records with only 2 or 3 fields for example), I tried :
function TServiceBiolife.BiolifeReadFromName(Common_Name: RawUTF8): RawJSON;
var aBioLife: TSQLBiolife;
//tmpResult : ???; What to do here?
begin;
TAutoFree.Create (aBioLife,TSQLBiolife.CreateAndFillPrepare(aServer,'Common_Name LIKE ' + QuotedStr(Common_Name + '%')));
While aBiolife.FillOne do
begin
Writeln (aBioLife.Common_Name); //This works as expected
//tmpResult.AddItem( with Only Needed Fields) ; //What to do here?
end;
//result := ObjectToJSON (tmpResult); //What to do here?
end;
Please if you have some examples , it would help.
Offline
I wrote this and It works fine.
function TServiceBiolife.BiolifeReadFromName(Common_Name: RawUTF8): RawJSON;
begin;
result:= aServer.RetrieveListJSON( TSQLBiolife, 'Common_Name LIKE ' + QuotedStr(Common_Name + '%') , 'Common_Name,Category', True);
end;
Thanks a lot ab.
Offline