#1 2023-06-13 08:26:36

yanchung
Member
Registered: 2023-06-13
Posts: 10

TForm1 is not part of TSQLMODEL root?

Hello every one

When I create my client as VCL App.  I got this error: TForm1 is not part of TSQLMODEL root

When I create my client as console App. it works just fine.

What do I miss here?

Delphi 10.4.2
Mormot 1 2023

Offline

#2 2023-06-13 09:11:10

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,150
Website

Re: TForm1 is not part of TSQLMODEL root?

Your is likely to be incorrect about a variable named "Name".
You are using TForm.Name and not the expected Name variable.

Offline

#3 2023-06-13 11:15:05

yanchung
Member
Registered: 2023-06-13
Posts: 10

Re: TForm1 is not part of TSQLMODEL root?

Thank you AB, now works fine

Offline

#4 2023-06-13 11:40:57

yanchung
Member
Registered: 2023-06-13
Posts: 10

Re: TForm1 is not part of TSQLMODEL root?

When I run my clint it took more than 2s to insert one record!

QeJTJ.png

How can I make it faster?

Server: localhost
Client: on the same computer (local)

Server:

procedure TForm1.FormCreate(Sender: TObject);
begin
  Model := TSQLModel.Create([TNote],'root');
  DB := TSQLRestServerDB.Create(Model,ChangeFileExt(paramstr(0),'.db3'));
  DB.CreateMissingTables;
  Server := TSQLHttpServer.Create('8080',[DB],'+',useHttpApiRegisteringURI);
  Server.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries
end;

Client:

begin
aModel := TSQLModel.Create([TNote],'root');;
  try
    aClient := TSQLHttpClientWinHTTP.Create('localhost','8080',aModel);
    try
      writeln('Add a new TPerson');
      timer.Start;
      aPerson := TNote.Create;
      try
        Randomize;
        aPerson.Body := 'eliaasoooo'+Int32ToUtf8(Random(10000000));
        aID := aClient.Add(aPerson,true);
      finally
        aPerson.Free;
      end;
       writeln('Processed in ',Ansi7ToString(Timer.Stop));
      writeln('Added TPerson.ID=',aID);
      aPerson := TNote.Create(aClient,aID);
      try
        writeln('Name read for ID=',aPerson.ID,' from DB = "',aPerson.Body,'"');
      finally
        aPerson.Free;
      end;
    finally
      aClient.Free;
    end;
    write(#10'Press [Enter] to quit');
    readln;
  finally
    aModel.Free;
  end;
end.

Using Postman -> post -> 41ms

Qtr8L.png

Last edited by yanchung (2023-06-13 12:59:34)

Offline

#5 2023-06-13 15:04:25

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,150
Website

Re: TForm1 is not part of TSQLMODEL root?

I am not able to reproduce it here.

Do you have a proxy or a particular corporate network configuration on this PC?
Did you try on another computer?

Try to debug a bit to find out what low-level API call takes 2 seconds.
Try to use TSqlRestHttpClientWinSock instead of the WinHTTP.

And for any new project, consider mORMot 2 instead of mORMot 1.

Offline

#6 2023-06-14 09:40:07

yanchung
Member
Registered: 2023-06-13
Posts: 10

Re: TForm1 is not part of TSQLMODEL root?

I hosted my Server in Remote VPS and it now takes ~552 ms.

Offline

Board footer

Powered by FluxBB