Docs Menu
Docs Home
/ / /
PHP ライブラリ マニュアル
/ / /

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_"
}
  • MongoDB\Database::createCollection()

  • MongoDB マニュアルのlistCollectionsコマンド参照

戻る

getCappedSize()

項目一覧