FireDAC.Phys.MongoDBWrapper.TMongoIndex
Delphi
TMongoIndex = class(TObject)
C++
class PASCALIMPLEMENTATION TMongoIndex : public System::TObject
Contents
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
class | public | FireDAC.Phys.MongoDBWrapper.pas FireDAC.Phys.MongoDBWrapper.hpp |
FireDAC.Phys.MongoDBWrapper | FireDAC.Phys.MongoDBWrapper |
Description
Fluent MongoDB index definition builder.
You can create an instance of TMongoIndex directly. To add your index to a collection, use TMongoCollection.CreateIndex.
The Keys method returns a builder for index keys.
You can use the Options property to specify the name of the index and other attributes.
Example
The following example shows how to define an index of three fields in ascending order.
MongoDB shell:
{ a: 1, b: 1, c: 1 }
Delphi:
MyIndex := TMongoIndex.Create(MyConnection.Env);
MyIndex.Keys.Ascending(['a', 'b', 'c']);
C++:
TMongoIndex* MyIndex = new TMongoIndex(MyConnection->Env);
MyIndex->Keys()->Ascending(OPENARRAY(String, ("a", "b", "c")));