对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

MongoDB\Model\CollectionInfo::getIdIndex()

1.9版本新增。:

MongoDB\Model\CollectionInfo::getIdIndex()

返回有关_id字段索引的信息。

function getIdIndex(): array

包含_id索引信息的大量。 这对应于listCollections命令回复中返回的idIndex字段。

<?php
$db = (new MongoDB\Client)->test;
$db->createCollection('myCollection');
// Retrieves the _id index information
foreach ($db->listCollections(['filter' => ['name' => 'myCollection']]) as $info) {
var_dump($info->getIdIndex());
}

而输出将类似如下所示:

array(3) {
'v' =>
int(2)
'key' =>
array(1) {
'_id' =>
int(1)
}
'name' =>
string(4) "_id_"
}