Documentation

Count
in package
implements Executable, Explainable

Operation for the count command.

Tags
see
Collection::count()
see
http://docs.mongodb.org/manual/reference/command/count/

Interfaces, Classes, Traits and Enums

Executable
Explainable

Table of Contents

$collectionName  : string
$databaseName  : string
$filter  : array<string|int, mixed>|object
$options  : array<string|int, mixed>
__construct()  : mixed
Constructs a count command.
execute()  : int
Execute the operation.
getCommandDocument()  : array<string|int, mixed>
Returns the command document for this operation.
createCommandDocument()  : array<string|int, mixed>
Create the count command document.
createOptions()  : array<string|int, mixed>
Create options for executing the command.

Properties

$collectionName

private string $collectionName

$databaseName

private string $databaseName

$filter

private array<string|int, mixed>|object $filter

$options

private array<string|int, mixed> $options

Methods

__construct()

Constructs a count command.

public __construct(string $databaseName, string $collectionName[, array<string|int, mixed>|object $filter = [] ][, array<string|int, mixed> $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
$databaseName : string

Database name

$collectionName : string

Collection name

$filter : array<string|int, mixed>|object = []

Query by which to filter documents

$options : array<string|int, mixed> = []

Command options

Tags
throws
InvalidArgumentException

for parameter/option parsing errors

Return values
mixed —

execute()

Execute the operation.

public execute(Server $server) : int
Parameters
$server : Server
Tags
see
Executable::execute()
throws
UnexpectedValueException

if the command response was malformed

throws
UnsupportedException

if read concern is used and unsupported

throws
RuntimeException

for other driver errors (e.g. connection errors)

Return values
int —

getCommandDocument()

Returns the command document for this operation.

public getCommandDocument(Server $server) : array<string|int, mixed>
Parameters
$server : Server
Tags
see
Explainable::getCommandDocument()
Return values
array<string|int, mixed> —

createCommandDocument()

Create the count command document.

private createCommandDocument() : array<string|int, mixed>
Return values
array<string|int, mixed> —

Search results