Docs Menu

MongoDB\Model\IndexInfo::isUnique()

MongoDB\Model\IndexInfo::isUnique()

Return whether the index is a unique index. This correlates with the unique option for MongoDB\Collection::createIndex().

function isUnique(): boolean

A boolean indicating whether the index is a unique index.

<?php
$info = new IndexInfo([
'unique' => true,
]);
var_dump($info->isUnique());

The output would then resemble:

bool(true)