#1 Re: mORMot 1 » Retriving (and storing) JSON from One-to-Many relation » 2020-01-10 12:59:24

When i see it correct, i cant do what i want.
I dont see Functions to encode JSON from an one-to many Relation.
So i have to use an own HTTPServer Implementation that manually calls PrepareFillMany and builds the JSON on its own and vice versa.

Right ?

Alternatively i have to get the detail data from Client side for every table with an separate call. Am i right ?

#2 Re: mORMot 1 » Retriving (and storing) JSON from One-to-Many relation » 2020-01-10 11:22:36

The Question is how can i tell TSQLHttpServer/TSQLRestServerDB that it please should use PrepareFillMany internally to build the JSON.
And is the JSON Generator able to build an nested JSON and also is it able to react to an PUT statement of teh nested Option part correct.

Or do i have to use an own HTTPServer Implementation that manually calls PrepareFillMany and builds the JSON on its own and vice versa.

#3 Re: mORMot 1 » Retriving (and storing) JSON from One-to-Many relation » 2020-01-10 11:20:42

I at time use only the predefined functions and the classes provided by mORMot

  SQLite3 := TSQLite3LibraryDynamic.Create;
  FDB := TSQLRestServerDB.Create(Model, ':memory:');
  FDB.CreateMissingTables(0,[itoNoAutoCreateGroups, itoNoAutoCreateUsers,itoNoCreateMissingField]);
  HttpServer := TSQLHttpServer.Create('8085', [FDB],'+', useBidirSocket);

The model looks like in the first post (i hope this amount of code is ok)
When i retrive now http://localhost:8085/promet/user/1000262/
Ill get only the record of the TUser dataset but i expect to get an nested JSON with TUser and TOptions nested.

#4 mORMot 1 » CreateMissingTables on an Model with a lot of external Tables » 2020-01-10 07:41:20

cutec-chris
Replies: 1

Ive noticed that CreateMissingTables on external Tables is pretty slow when the Model is quite Big.
Is there an prefered way to work around that ?
At example by defining more models and loading them when needed or something like that ?

When i understand it right, thats basically becouse mormot fires an select to any registered table (to get Field names?)
Maybe its possible to do that asynchronious later or something like that ?

#5 Re: mORMot 1 » Retriving (and storing) JSON from One-to-Many relation » 2020-01-09 21:44:04

Ive read this stuff 4-5 times, maybe my english isn't not good enough but i don't find answers there to the above questions.

Does TSQLRestServerDB has the ability to return nested Json for one-to-many mapping ? It just dont shows the options field to me in an request.

#6 mORMot 1 » Retriving (and storing) JSON from One-to-Many relation » 2020-01-09 14:15:05

cutec-chris
Replies: 8

Hello,

iam starting to learn mORMot at time smile
And ill try to move my old Business Logic to mormot at time.
Ive managed to connect to one of my existing Database, and retriving Tables via TSQLRestServerDB/TSQLHttpServer.
Now ill try to retrive an nested record from an standard master/detail relation in the database.

  TOption = class(TBaseDBDataSet)
  private
    FOption,FValue : RawUTF8;
    fREF_ID : TRecordReference;
  public
    class procedure DefineFields(aDataSet : TDataSet);override;
  published
    property REF_ID: TRecordReference read fREF_ID write fREF_ID;
    property OPTION : RawUTF8 index 60 read FOption;
    property VALUE : RawUTF8 write FValue;
  end;
  TUser = class;
  TOptions = class(TSQLRecordMany)
  private
    FOption: TOption;
    FUser: TUser;
  public
    function GetOption(aSection, aIdent, DefaultValue: string): string;
    procedure SetOption(aSection,aIdent, Value : string);
  published
    property Source : TUser read FUser;
    property Dest : TOption read FOption;
  end;
  TUser = class(TBaseDBDataset)
  private

But ill get always only the first level of the relation.
Is this not implemented ? Or do i have to set an Option to TSQLRestServerDB ?
When its not implemented, whers the best way to start ?
Do i have to retrive the Data manually ? (What function can i override to do so ?)

best regards
Christian

Board footer

Powered by FluxBB