Menu Docs

Página inicial do DocsManual da Biblioteca PHP

MongoDB\Model\IndexInfo::is2dSphere()

Nesta página

  • Definição
  • Valores de retorno
  • Exemplos
  • Veja também

Novidade na versão 1.4.

MongoDB\Model\IndexInfo::is2dSphere()

Retorne se o índice é um índice2 .

function is2dSphere(): boolean

Um booleano que indica se o índice é um índice 2dsphere.

<?php
$collection = (new MongoDB\Client)->selectCollection('test', 'places');
$collection->createIndex(['pos' => '2dsphere']);
foreach ($collection->listIndexes() as $index) {
if ($index->is2dSphere()) {
printf("%s has 2dsphereIndexVersion: %d\n", $index->getName(), $index['2dsphereIndexVersion']);
}
}

A saída seria então semelhante a:

pos_2dsphere has 2dsphereIndexVersion: 3
← MongoDB\Model\IndexInfo::getVersion()