You are not logged in.
Pages: 1
Are there any plans to add support for nested classes in the Cross-Platform?
Offline
What do you call "nested classes"?
Joined ORM fields?
The idea with cross-platform clients is that you rather define DTO objects, not directly access complex ORM classes.
There is no plan to support it yet.
But any input is welcome!
Offline
I meant something like this:
TMyParams = class
private
FP1: Boolean;
published
property P1: Boolean read FP1 write FP1;
end;
TMyRec = class(TSQLRecord)
private
FTitle: string;
FParams: TMyParams;
public
destructor Destroy; override; // to destroy FParams
class function NewInstance: TObject {$IFDEF AUTOREFCOUNT} unsafe {$ENDIF}; override; // need override NewInstance to create FParams (constructor TObjects isn't virtual)
published
property Title: string read FTitle write FTitle;
property Params: TMyParams read FParams write FParams;
end;
const
cStoreClassName = True;
...
r := TMyRec.Create;
try
r.Title := 'Hello';
r.Params.P1 := True;
aJSON := ObjectToJSON(r, cStoreClassName);
finally
r.Free;
end;
r := TMyRec(JSONToNewObject(aJSON))
I made some tests.
1. The function ObjectToJSON have parameter StoreClassName: boolean=false. So we don't have ClassName to create nested classes in SynCrossPlatformREST by default. Is it possible to make it customizable?
2. The code works on Win32. On Android there is a problem with
function JSONToNewObject(const JSON: string): pointer;
should be
function JSONToNewObject(const JSON: string): TObject;
And a question. Is it possible to somehow teach the mORMotWrappers to generate nested classes? Or should I put them in the template? Or I should use nested records and arrays?
Offline
Offline
Thanks, ab
Offline
Pages: 1