文档菜单
文档首页
/ / /
PHP库手册
/ / /

MongoDB\Model\CollectionInfo::getIdIndex()

本页内容

  • 定义
  • 返回值
  • 示例
  • 参见

新增在版本1.9.

MongoDB\Model\CollectionInfo::getIdIndex()

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

function getIdIndex(): array

一个包含关于 _id 索引信息的数组。这对应于在 listCollections 命令回复中返回的 idIndex 字段。

<?php
$info = new CollectionInfo([
'type' => 'view',
'name' => 'foo',
'idIndex' => [
'v' => 2,
'key' => ['_id' => 1],
'name' => '_id',
'ns' => 'test.foo',
],
]);
var_dump($info->getIdIndex());

输出将类似于

array(4) {
["v"]=>
int(2)
["key"]=>
array(1) {
["_id"]=>
int(1)
}
["name"]=>
string(3) "_id"
["ns"]=>
string(8) "test.foo"
}
  • MongoDB数据库::createCollection()

  • listCollections 命令参考 MongoDB 手册

返回

getCappedSize()