B
B
bizzonaru2016-12-09 11:47:19
Yii
bizzonaru, 2016-12-09 11:47:19

Index not created in mongoDB from yii-mongodb during migration?

  1. MongoDB shell version: 2.4.14
> create indexes on views ([{"key":{"id":1,"types":1},"name":"id_types_idx"}                                                       ]) ...Exception 'yii\mongodb\Exception' with message 'no such cmd: createIndexes

class m161208_132616_mongodb_add_index_to_view_collection extends \yii\mongodb\Migration
{

    public function init()
    {
        $this->db = Yii::$app->mongodb;
        parent::init();
    }


    public function up() 
    {
        $this->createIndexes('views', [
          [
            'key' => [
                'id' => 1, 
                'types' => 1,
            ],
            'name' => 'id_types_idx'
          ],
        ]);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bizzonaru, 2016-12-09
@bizzonaru

(
    [command] => stdClass Object
        (
            [createIndexes] => views
            [indexes] => Array
                (
                    [0] => stdClass Object
                        (
                            [key] => stdClass Object
                                (
                                    [id] => 1
                                    [types] => 1
                                )

                            [name] => id_types_idx
                            [ns] => dev_statistics.views
                        )

                )

        )

)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question