FireDAC.Phys.MongoDBWrapper.TMongoPipeline
Delphi
TMongoPipeline = class(TInterfacedObject, IMongoCursor)
C++
class PASCALIMPLEMENTATION TMongoPipeline : public System::TInterfacedObject
プロパティ
種類 | 可視性 | ソース | ユニット | 親 |
---|---|---|---|---|
class | public | FireDAC.Phys.MongoDBWrapper.pas FireDAC.Phys.MongoDBWrapper.hpp |
FireDAC.Phys.MongoDBWrapper | FireDAC.Phys.MongoDBWrapper |
説明
フルーエント スタイルの MongoDB パイプライン ビルダを表します。
TMongoPipeline オブジェクトは、次のような状況で使用することができます。
- パイプライン オブジェクトを明示的に作成し、TMongoCollection.Aggregate メソッドにそれを投稿します。このシナリオでは、パイプライン オブジェクトを再利用できます。
- オーバーロードされた TMongoCollection.Aggregate メソッドからパイプライン オブジェクトを取得し、それを IMongoCursor にキャストしてパイプラインを実行して、結果セットのカーソルを取得します。
次のメソッドを使用して、パイプラインのステージを定義することができます:
また、パイプラインのオプションを定義することもできます。
例
次のコード スニペットは、コレクションを集約パイプラインに渡す方法を示しており、その後、各区画に対するドキュメントの数をカウントします。出力リストは、count
フィールドでソートされます。
メモ: 詳細は、MongoDB Restaurants サンプル プロジェクトを参照してください。
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();