FireDAC.Phys.MongoDBWrapper.TMongoCollection.Find
Delphi
function Find(AQuery: TMongoQuery; AFlags: TMongoQueryFlags = []): IMongoCursor; overload;
function Find(AFlags: TMongoQueryFlags = []): TMongoQuery; overload;
C++
_di_IMongoCursor __fastcall Find(TMongoQuery* AQuery, TMongoQueryFlags AFlags = TMongoQueryFlags() )/* overload */;
TMongoQuery* __fastcall Find(TMongoQueryFlags AFlags = TMongoQueryFlags() )/* overload */;
Contents
Properties
| Type | Visibility | Source | Unit | Parent | 
|---|---|---|---|---|
| function | public | FireDAC.Phys.MongoDBWrapper.pas FireDAC.Phys.MongoDBWrapper.hpp | FireDAC.Phys.MongoDBWrapper | TMongoCollection | 
Description
Finds documents of the collection that match the specified query and returns a cursor to access the results.
Find supports two different coding styles.
You can optionally specify a set of query flags.
Example
The following example obtains the first 3 Italian restaurants in the 10075 zip code, sorted alphabetically.
MongDB shell:
db.restaurants.find({ cuisine: "Italian", "address.zipcode": "10075" }).sort({ name: 1 }).limit(3)
Delphi:
MyCursor := MyCollection.Find
  .Match
    .Add('cuisine', 'Italian')
    .Add('address.zipcode', '10075')
  .&End
  .Sort
    .Ascending(['name'])
  .&End
  .Limit(3);
C++:
_di_IMongoCursor MyCursor = MyCollection->Find()
  ->Match()
    ->Add("cuisine", String("Italian"))
    ->Add("address.zipcode", String("10075"))
  ->End()
  ->Sort()
    ->Ascending(OPENARRAY((String("name"))))
  ->End()
  ->Limit(3)
  ->Open();