Phalcon\Db\Adapter\MongoDB\Operation\DropIndexes::execute PHP Method

execute() public method

Execute the operation.
See also: Executable::execute()
public execute ( MongoDB\Driver\Server $server ) : array | object
$server MongoDB\Driver\Server
return array | object Command result document
    public function execute(Server $server)
    {
        $cmd = ['dropIndexes' => $this->collectionName, 'index' => $this->indexName];
        $cursor = $server->executeCommand($this->databaseName, new Command($cmd));
        if (isset($this->options['typeMap'])) {
            $cursor->setTypeMap($this->options['typeMap']);
        }
        return current($cursor->toArray());
    }

Usage Example

Beispiel #1
0
 /**
  * Drop all indexes in the collection.
  *
  * @see DropIndexes::__construct() for supported options
  *
  * @param array $options Additional options
  *
  * @return array|object Command result document
  */
 public function dropIndexes(array $options = [])
 {
     if (!isset($options['typeMap'])) {
         $options['typeMap'] = $this->typeMap;
     }
     $operation = new DropIndexes($this->databaseName, $this->collectionName, '*', $options);
     $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
     return $operation->execute($server);
 }