You are viewing an offline version of MongoDB documentation. Some page features might be unavailable. To view the latest version of the page or use interactive features, visit the live page.
MongoDB\Model\IndexInfo::getKey()
Definition
MongoDB\Model\IndexInfo::getKey()Return the index specification (i.e. indexed field(s) and order). This correlates with the
$keyparameter forMongoDB\Collection::createIndex().function getKey(): array
Return Values
The index specification as an associative array.
Examples
$info = new IndexInfo([ 'key' => ['x' => 1], ]); var_dump($info->getKey());
The output would then resemble:
array(1) { ["x"]=> int(1) }
See Also
listIndexes command reference in the MongoDB manual