AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
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()

1.9バージョン の新機能。:

MongoDB\Model\CollectionInfo::getType()

コレクションの種類を返します。

function getType(): string

コレクションの種類。 これは、 listCollectionsコマンドの応答で返されるtypeフィールドに対応します。

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

出力は次のようになります。

collection