Make the MongoDB docs better! We value your opinion. Share your feedback for a chance to win $100.
Click here >
Docs Menu
Docs Home
/ /

MongoDB\Model\CollectionInfo::getIdIndex()

Nuevo en la versión 1.9.

MongoDB\Model\CollectionInfo::getIdIndex()

Retorna información sobre el índice de campo _id.

function getIdIndex(): array

Un arreglo que contiene información sobre el índice _id. Esto corresponde al campo idIndex devuelto en la respuesta del comando listCollections.

<?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());
}

La vista de salida se ilustraría como sigue:

array(3) {
'v' =>
int(2)
'key' =>
array(1) {
'_id' =>
int(1)
}
'name' =>
string(4) "_id_"
}
  • MongoDB\Database::createCollection()

  • Referencia del comando listCollections en el manual de MongoDB

Volver

getCappedSize()

En esta página