yii\mongodb\Migration::createIndex PHP Method

createIndex() public method

Creates an index on the collection and the specified fields.
public createIndex ( string | array $collection, array | string $columns, array $options = [] )
$collection string | array name of the collection
$columns array | string column name or list of column names.
$options array list of options in format: optionName => optionValue.
    public function createIndex($collection, $columns, $options = [])
    {
        $this->beginProfile($token = "    > create index on " . $this->composeCollectionLogName($collection) . " (" . Json::encode((array) $columns) . empty($options) ? "" : ", " . Json::encode($options) . ") ...");
        $this->db->getCollection($collection)->createIndex($columns, $options);
        $this->endProfile($token);
    }