Operation for the distinct command.
- Full name:
\MongoDB\Operation\Distinct
- This class implements:
\MongoDB\Operation\Executable
,\MongoDB\Operation\Explainable
See Also:
- \MongoDB\Collection::distinct() -
- http://docs.mongodb.org/manual/reference/command/distinct/ -
private string $databaseName
private string $collectionName
private string $fieldName
private array|object $filter
private array $options
Constructs a distinct command.
public __construct(string $databaseName, string $collectionName, string $fieldName, array|object $filter = [], array $options = []): mixed
Supported options:
-
collation (document): Collation specification.
-
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.
-
typeMap (array): Type map for BSON deserialization.
Parameters:
Parameter | Type | Description |
---|---|---|
$databaseName |
string | Database name |
$collectionName |
string | Collection name |
$fieldName |
string | Field for which to return distinct values |
$filter |
array|object | Query by which to filter documents |
$options |
array | Command options |
Execute the operation.
public execute(\MongoDB\Driver\Server $server): array
Parameters:
Parameter | Type | Description |
---|---|---|
$server |
\MongoDB\Driver\Server |
See Also:
- \MongoDB\Operation\Executable::execute() -
Returns the command document for this operation.
public getCommandDocument(\MongoDB\Driver\Server $server): array
Parameters:
Parameter | Type | Description |
---|---|---|
$server |
\MongoDB\Driver\Server |
See Also:
- \MongoDB\Operation\Explainable::getCommandDocument() -
Create the distinct command document.
private createCommandDocument(): array
Create options for executing the command.
private createOptions(): array
See Also: