Skip to content

Latest commit

 

History

History
216 lines (85 loc) · 2.43 KB

CountDocuments.md

File metadata and controls

216 lines (85 loc) · 2.43 KB

CountDocuments

Operation for obtaining an exact count of documents in a collection

See Also:

Properties

databaseName

private string $databaseName

collectionName

private string $collectionName

filter

private array|object $filter

aggregateOptions

private array $aggregateOptions

countOptions

private array $countOptions

aggregate

private \MongoDB\Operation\Aggregate $aggregate

Methods

__construct

Constructs an aggregate command for counting documents

public __construct(string $databaseName, string $collectionName, array|object $filter, array $options = []): mixed

Supported options:

  • collation (document): Collation specification.

  • hint (string|document): The index to use. Specify either the index name as a string or the index key pattern as a document. If specified, then the query system will only consider plans using the hinted index.

  • limit (integer): The maximum number of documents to count.

  • maxTimeMS (integer): The maximum amount of time to allow the query to run.

  • readConcern (MongoDB\Driver\ReadConcern): Read concern.

  • readPreference (MongoDB\Driver\ReadPreference): Read preference.

  • session (MongoDB\Driver\Session): Client session.

  • skip (integer): The number of documents to skip before returning the documents.

Parameters:

Parameter Type Description
$databaseName string Database name
$collectionName string Collection name
$filter array|object Query by which to filter documents
$options array Command options

execute

Execute the operation.

public execute(\MongoDB\Driver\Server $server): int

Parameters:

Parameter Type Description
$server \MongoDB\Driver\Server

See Also:

  • \MongoDB\Operation\Executable::execute() -

createAggregate

private createAggregate(): \MongoDB\Operation\Aggregate