FireDAC.Phys.MongoDBWrapper.TMongoQuery

From RAD Studio API Documentation
Jump to: navigation, search

System.TInterfacedObjectSystem.TObjectTMongoQuery

Delphi

TMongoQuery = class(TInterfacedObject, IMongoCursor)

C++

class PASCALIMPLEMENTATION TMongoQuery : public System::TInterfacedObject

Properties

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

Description

Represents a fluent style MongoDB query builder.

The builder key methods, such as Project, Match, or Sort, return subbuilders for corresponding query parts.

You can use a TMongoQuery object in the following scenarios:

In this scenario, you can reuse the query object.

Examples

To clarify, consider the following examples. These code snippets illustrate how to fetch specific records from the 'restaurants' collection in the 'test' database.

Delphi:

var
  FDConnection1: TFDConnection;
  oCon: TMongoConnection;
  oCrs : IMongoCursor;
begin
  oCon:= TMongoConnection(FDConnection1.CliObj);
  oCrs := oCon['test']['restaurants'].Find
    .Match
      .Add('cuisine', 'Italian')
      .Add('address.zipcode', '10075')
    .&End
    .Sort
      .Field('Name', True)
    .&End
    .Limit(5);
end;

C++Builder:

  TFDConnection *FDConnection1;
  TMongoConnection *oCon = static_cast<TMongoConnection*>(FDConnection1->CliObj);
  _di_IMongoCursor  oCrs;

  oCrs = interface_cast<IMongoCursor>(oCon->Databases["test"]->Collections["restaurants"]->Find()
    ->Match()
      ->Add("cuisine","Italian")
      ->Add("address.zipcode", "10075")
    ->End()
    ->Sort()
      ->Field("Name",true)
    ->End()
    ->Limit(5));

See Also