FireDAC.Phys.MongoDBDataSet.TFDMongoQuery
提供: RAD Studio API Documentation
TFDMongoQuery
Delphi
TFDMongoQuery = class (TFDMongoCustomDataSet)
C++
class PASCALIMPLEMENTATION TFDMongoQuery : public TFDMongoCustomDataSet
プロパティ
| 種類 | 可視性 | ソース | ユニット | 親 |
|---|---|---|---|---|
| class | public | FireDAC.Phys.MongoDBDataSet.pas FireDAC.Phys.MongoDBDataSet.hpp |
FireDAC.Phys.MongoDBDataSet | FireDAC.Phys.MongoDBDataSet |
説明
TFDMongoQuery クラスは MongoDB クエリの実行に使用されます。
クエリを指定する方法は次のいずれかです。
クエリを実行するには、Connection、DatabaseName、CollectionName の各プロパティを指定します。
例
具体的に説明するために、以下の例を考えてみましょう。これらのコード例では、'test' データベース内の 'restaurants' コレクションから特定のレコードを取得する方法を示しています。
メモ: これらのコード例は、MongoDB DataSet サンプル プロジェクトから抜き出したものです。このサンプルの詳細については、MongoDB.DataSet サンプルを参照してください。
Delphi の場合:
procedure TfrmMain.FormCreate(Sender: TObject); begin // Setting the Mode to fmAll helps you measure the fetch performance FDMongoQuery1.FetchOptions.Mode := fmAll; // Setting the CachedUpdates to True helps you measure the update performance FDMongoQuery1.CachedUpdates := True; end; // This event handler executes a query specified in the FDMongoQuery1.QMatch property. procedure TfrmMain.Button1Click(Sender: TObject); begin FDMongoQuery1.Close; FDMongoQuery1.QMatch := '{"cuisine": "Italian", "address.zipcode": "10075"}'; FDMongoQuery1.Open; // ...... end;
C++Builder の場合:
void __fastcall TfrmMain::FormCreate(TObject *Sender) { // Setting the Mode to fmAll helps you measure the fetch performance FDMongoQuery1->FetchOptions->Mode << fmAll; // Setting the CachedUpdates to True helps you measure the update performance FDMongoQuery1->CachedUpdates = true; } //--------------------------------------------------------------------------- // This event handler executes a query specified in the FDMongoQuery1->QMatch property. void __fastcall TfrmMain::Button1Click(TObject *Sender) { FDMongoQuery1->Close(); FDMongoQuery1->QMatch = "{'cuisine': 'Italian', 'address.zipcode': '10075'}"; FDMongoQuery1->Open(); // ..... }