private function createCommand(Server $server)
{
$cmd = ['distinct' => $this->collectionName, 'key' => $this->fieldName];
if (!empty($this->filter)) {
$cmd['query'] = (object) $this->filter;
}
if (isset($this->options['maxTimeMS'])) {
$cmd['maxTimeMS'] = $this->options['maxTimeMS'];
}
if (isset($this->options['readConcern']) && Functions::serverSupportsFeature($server, self::$wireVersionForReadConcern)) {
$cmd['readConcern'] = Functions::readConcernAsDocument($this->options['readConcern']);
}
return new Command($cmd);
}