Sokil\Mongo\Collection::ensureIndex PHP Method

ensureIndex() public method

Create index
Deprecation: since 1.19 Use self::createIndex()
public ensureIndex ( array $key, array $options = [] ) : Collection
$key array
$options array see @link http://php.net/manual/en/mongocollection.ensureindex.php
return Collection
    public function ensureIndex(array $key, array $options = array())
    {
        return $this->createIndex($key, $options);
    }

Usage Example

Example #1
0
 public function testDeleteIndex()
 {
     $this->collection->ensureIndex(array('asc' => 1, 'desc' => -1));
     $this->collection->deleteIndex(array('asc' => 1, 'desc' => -1));
     $indexes = $this->collection->getIndexes();
     $this->assertEquals(1, count($indexes));
 }
All Usage Examples Of Sokil\Mongo\Collection::ensureIndex