FireDAC.Phys.MongoDBWrapper.TMongoCollection.Count

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function Count(AQuery: TMongoQuery; AFlags: TMongoQueryFlags = []): Int64; overload;
function Count(AFlags: TMongoQueryFlags = []): TMongoQuery; overload;

C++

__int64 __fastcall Count(TMongoQuery* AQuery, TMongoQueryFlags AFlags = TMongoQueryFlags() )/* overload */;
TMongoQuery* __fastcall Count(TMongoQueryFlags AFlags = TMongoQueryFlags() )/* overload */;

Properties

Type Visibility Source Unit Parent
function public
FireDAC.Phys.MongoDBWrapper.pas
FireDAC.Phys.MongoDBWrapper.hpp
FireDAC.Phys.MongoDBWrapper TMongoCollection

Description

Returns the number of documents of the collection that match the specified query.

Count supports two different coding styles.

You can optionally specify a set of query flags.

Example

The following example obtains the number of Italian restaurants in the 10075 zip code.

MongDB shell:

db.restaurants.count({ cuisine: "Italian", "address.zipcode": "10075" })

Delphi:

Count := MyCollection.Count
  .Match
    .Add('cuisine', 'Italian')
    .Add('address.zipcode', '10075')
  .&End
  .Value;

C++:

int Count = MyCollection->Count()
  ->Match()
    ->Add("cuisine", String("Italian"))
    ->Add("address.zipcode", String("10075"))
  ->End()
  ->Value();

See Also