Phalcon\Db\Adapter\MongoDB\Operation\ListIndexes::executeCommand PHP Method

executeCommand() private method

Returns information for all indexes for this collection using the listIndexes command.
private executeCommand ( MongoDB\Driver\Server $server ) : IndexInfoIteratorIterator
$server MongoDB\Driver\Server
return Phalcon\Db\Adapter\MongoDB\Model\IndexInfoIteratorIterator
    private function executeCommand(Server $server)
    {
        $cmd = ['listIndexes' => $this->collectionName];
        if (isset($this->options['maxTimeMS'])) {
            $cmd['maxTimeMS'] = $this->options['maxTimeMS'];
        }
        try {
            $cursor = $server->executeCommand($this->databaseName, new Command($cmd));
        } catch (RuntimeException $e) {
            /* The server may return an error if the collection does not exist.
             * Check for possible error codes (see: SERVER-20463) and return an
             * empty iterator instead of throwing.
             */
            if ($e->getCode() === self::$errorCodeNamespaceNotFound || $e->getCode() === self::$errorCodeDatabaseNotFound) {
                return new IndexInfoIteratorIterator(new EmptyIterator());
            }
            throw $e;
        }
        $cursor->setTypeMap(['root' => 'array', 'document' => 'array']);
        return new IndexInfoIteratorIterator($cursor);
    }