For AI agents: a documentation index is available at https://www.mongodb.com/zh-cn/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Make the MongoDB docs better! We value your opinion. Share your feedback for a chance to win $100.
MongoDB Branding Shape
Click here >
Docs Menu

MongoDB\Model\CollectionInfo::getType()

New in version 1.9. :

MongoDB\Model\CollectionInfo::getType()

Return the collection type.

function getType(): string

The collection type. This corresponds to the type field returned in the listCollections command reply.

<?php
$db = (new MongoDB\Client)->test;
$db->createCollection('myCollection');
// Retrieves the collection type
foreach ($db->listCollections(['filter' => ['name' => 'myCollection']]) as $info) {
echo $info->getType();
}

The output would then resemble:

collection