FireDAC.Phys.MongoDBWrapper.TMongoPipeline

From RAD Studio API Documentation
Jump to: navigation, search

System.TInterfacedObjectSystem.TObjectTMongoPipeline

Delphi

TMongoPipeline = class(TInterfacedObject, IMongoCursor)

C++

class PASCALIMPLEMENTATION TMongoPipeline : 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 pipeline builder.

You can use a TMongoPipeline object in the following scenarios:

You can use the following methods to define stages of the pipeline:

You can also define some options for your pipeline.

Examples

The following code snippets illustrate how to pass a collection into the aggregation pipeline, and then count the number of documents for each borough. The output list is sorted by the count field.

Note: For more information, see the MongoDB Restaurants sample project.

Delphi:

 var
  oCrs: IMongoCursor;
  oCrs := FCon['test']['restaurants'].Aggregate()
    .Group
      .Add('_id', '$borough')
      .BeginObject('count')
        .Add('$sum', 1)
      .EndObject
    .&End
    .Sort('{ count: 1 }').&End;

C++Builder:

di_IMongoCursor  oCrs = interface_cast<IMongoCursor>(MongoCon->Databases["test"]->Collections["restaurants"]->Aggregate())
->Group()
      ->Add("_id", "$borough")
      ->BeginObject("count")
        ->Add("$sum", 1)
      ->EndObject()
     ->End()
    ->Sort("{ count: 1 }")->End();

See Also