FireDAC.Phys.MongoDBWrapper.TMongoCommand

From RAD Studio API Documentation
Jump to: navigation, search

FireDAC.Phys.MongoDBWrapper.TMongoQuerySystem.TInterfacedObjectSystem.TObjectTMongoCommand

Delphi

TMongoCommand = class(TMongoQuery)

C++

class PASCALIMPLEMENTATION TMongoCommand : public TMongoQuery

Properties

Type Visibility Source Unit Parent
class public
FireDAC.Phys.MongoDBWrapper.pas
FireDAC.Phys.MongoDBWrapper.hpp
FireDAC.Phys.MongoDBWrapper FireDAC.Phys.MongoDBWrapper

Description

MongoDB command builder.

To be able to reuse an instance of TMongoCommand, create an instance explicitly, define the command that you want to execute, and pass that instance to the Command function of a connection, database or collection to submit your command and obtain a result set cursor. For example:

Delphi:

MyCommand := TMongoCommand.Create(MyConnection.Env);
MyCommand.Command('{ "ping": 1 }');
MyCursor := MyConnection.Command('my_database', MyCommand);

C++:

TMongoCommand* MyCommand = new TMongoCommand(MyConnection->Env);
MyCommand->Command("{ 'ping': 1 }");
_di_IMongoCursor MyCursor = MyConnection->Command("my_database", MyCommand);

Alternatively, you can obtain an instance of TMongoCommand from the Command function of a connection, database, or collection, and cast that instance to IMongoCursor. During that casting, your instance of TMongoCommand executes its command and obtains a result set cursor. For example:

Delphi:

MyCursor := IMongoCursor(MyConnection.Command('my_database', '{ "ping": 1 }'));

C++:

_di_IMongoCursor MyCursor = (_di_IMongoCursor) MyConnection->Command("my_database", "{ 'ping': 1 }");

See Also