Documentation

Distinct
in package
implements Explainable

FinalYes

Operation for the distinct command.

Tags
see
Collection::distinct()
see
https://mongodb.com/docs/manual/reference/command/distinct/

Table of Contents

Interfaces

Explainable

Properties

$collectionName  : string
$databaseName  : string
$fieldName  : string
$filter  : array<string|int, mixed>|object
$options  : array<string|int, mixed>

Methods

__construct()  : mixed
Constructs a distinct command.
execute()  : array<string|int, mixed>
Execute the operation.
getCommandDocument()  : array<string|int, mixed>
Returns the command document for this operation.
createCommandDocument()  : array<string|int, mixed>
Create the distinct 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 distinct command.

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

Supported options:

  • collation (document): Collation specification.

  • comment (mixed): BSON value to attach as a comment to this command.

    This is not supported for server versions < 4.4.

  • 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.

    This is not supported for server versions < 7.1.

  • 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
$databaseName : string

Database name

$collectionName : string

Collection name

$fieldName : string

Field for which to return distinct values

$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

execute()

Execute the operation.

public execute(Server $server) : array<string|int, mixed>
Parameters
$server : Server
Tags
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
array<string|int, mixed>

getCommandDocument()

Returns the command document for this operation.

public getCommandDocument() : array<string|int, mixed>
Tags
see
Explainable::getCommandDocument()
Return values
array<string|int, mixed>

createCommandDocument()

Create the distinct command document.

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

        
On this page

Search results