#1 2024-05-12 14:52:21

RaelB
Member
Registered: 2010-08-04
Posts: 57

RemoteDataCreate with TRestServerFullMemory?

Can RemoteDataCreate be used with TRestServerFullMemory, e.g. TRestServerFullMemory to use Auth tables from a TRestServerDB?

From docs it sounds like this is intended for a TRestServerDB to use tables from another TRestServerDB, but I'm not entirely sure. It does compile with TRestServerFullMemory though...

Offline

#2 2024-05-12 16:21:04

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

Re: RemoteDataCreate with TRestServerFullMemory?

IRestOrmServer.RemoteDataCreate is implemented by TRestOrmServer.RemoteDataCreate at TRestOrm level, so you could export a TRestServerFullMemory instance with no problem.

Offline

#3 2024-05-12 16:43:26

RaelB
Member
Registered: 2010-08-04
Posts: 57

Re: RemoteDataCreate with TRestServerFullMemory?

Not sure if I understand the word "export". Is it possible for a TRestServerFullMemory to use the Auth tables of a TRestServerDB instance?

If I try following code:

  TPublicServer = class(TRestServerFullMemory)...

  TDBServer = class(TRestServerDB)...

function CreateSampleModel: TOrmModel;
begin
  result := TOrmModel.Create([TOrmSample, TAuthGroup, TAuthUser,
    TOrmNote, TOrmNotebook]);
end;

// create servers
  Model := CreateSampleModel;
  DBServer := TDBServer.Create(Model,
    ChangeFileExt(Executable.ProgramFileName, '.db'));
  DBServer.db.Synchronous := smOff;
  DBServer.db.LockingMode := lmNormal; //lmExclusive;
  DBServer.server.CreateMissingTables;

  PublicServer := TPublicServer.CreateWithOwnModel(
    [TAuthGroup, TAuthUser], True
  );
  PublicServer.Server.RemoteDataCreate(TAuthUser, DBServer.OrmInstance);

I get error: Exception class ERestStorage with message 'Duplicated TRestOrmServerFullMemory.RemoteDataCreate(TAuthUser) as TRestStorageInMemory'.

With TRestServerFullMemory, as far as I can tell, there is no way for me to delay creation of external tables until after call to RemoteDataCreate..

Offline

#4 2024-05-12 17:02:19

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

Re: RemoteDataCreate with TRestServerFullMemory?

Now I understand.

A TRestServerFullMemory is a ... TRestServer in Full Memory. As its name states.
That is, all its tables are in-memory tables.
You can then assign a redirection via RemoteDataCreate() to any of those tables, which are already internal.

What you can do is define a TRestServerDB, then define some tables as in-memory statics tables, and some other as RemoteDataCreate.

Offline

Board footer

Powered by FluxBB