Docs Menu
Docs Home
/ /

MongoDB\Model\CollectionInfo::getIdIndex()

Nuevo en la versión 1.9.

MongoDB\Model\CollectionInfo::getIdIndex()

Devuelve información sobre el índice del 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());
}

El resultado sería entonces similar a lo siguiente:

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

  • Referencia del comandolistCollections en el manual de MongoDB

Volver

obtenerTamañoCapturado()

En esta página