MongoDB\Model\IndexInfo::is2dSphere()
新增在版本1.4.
定义
MongoDB\Model\IndexInfo::is2dSphere()
返回索引是否为2dsphere 索引。
function is2dSphere(): boolean
返回值
一个布尔值,表示索引是否为2dsphere索引。
示例
$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']); } }
输出将类似于
pos_2dsphere has 2dsphereIndexVersion: 3