Show: Object Pascal C++
Display Preferences

FireDAC.Phys.MongoDBWrapper.TMongoPipeline

From Appmethod Libraries
Jump to: navigation, search

System.TInterfacedObjectSystem.TObjectTMongoPipeline

Object Pascal

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.

The builder key methods, such as Project, Match, or Group, return subbuilders for corresponding pipeline stages.

You can use a TMongoPipeline object in the following scenarios:

In this scenario you can reuse the pipeline object.
  • Obtain the pipeline object from an overloaded TMongoCollection.Aggregate method, and then cast it to IMongoCursor to execute a pipeline and get a result set cursor.

Examples

The following code snippets illustate 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.

Object Pascal:

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

Appmethod C++:

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

Personal tools
Translations