#1 2023-01-17 09:19:06

larand54
Member
Registered: 2018-12-25
Posts: 65

MongoDB - Unsupported OP_QUERY command: hostInfo

Completely new to MongoDB and tried one of your old examples:
https://blog.synopse.info/?post/2014/05 … ase-access

Installed the latest version (6.03) of MongoDB
and tried:

var Client: TMongoClient;
    DB: TMongoDatabase;
    serverTime: TDateTime;
    res: variant; // we will return the command result as TDocVariant
    errmsg: RawUTF8;
begin
  Client := TMongoClient.Create('localhost',27017);
  try
    DB := Client.Database['mydb'];
    writeln('Connecting to ',DB.Name); // will write 'mydb'
    errmsg := DB.RunCommand('hostInfo',res); // run a command
    if errmsg<>'' then
      exit; // quit on any error
    serverTime := res.system.currentTime; // direct conversion to TDateTime
    writeln('Server time is ',DateTimeToStr(serverTime));
  finally
    Client.Free; // will release the DB instance
  end;
end;

and gets: 'Unsupported OP_QUERY command: db.hostInfo. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal'

Don't know if its possible use the latest version with mORMot1 any more or should I try with mORMot2?


Delphi-11, WIN10

Offline

#2 2023-01-17 10:28:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,503
Website

Re: MongoDB - Unsupported OP_QUERY command: hostInfo

Yes the mormot 2 driver has been update but not the mormot 1...

See https://blog.synopse.info/?post/2022/08 … /6-Support

Offline

#3 2023-01-17 10:56:55

larand54
Member
Registered: 2018-12-25
Posts: 65

Re: MongoDB - Unsupported OP_QUERY command: hostInfo

Ok, that's good. As I'm new to MongoDB it also makes sense to start MongoDB with mORMot2.
When I tried to set up mORMot2 on Delphi and followed the instructions from the ReadMe file I got this code to work.
:-)


Delphi-11, WIN10

Offline

Board footer

Powered by FluxBB