The createIndexes db.runCommand from Chapter1 "Basic Commands" syntax is wrong

Hi @Kushagra_Kesav, when I go over m103 I found the the video of Chapter one, lecture "Basic Commands " at 3:17 and lecture notes all gave the wrong format as:

db.runCommand(
  { "createIndexes": <collection> },
  { "indexes": [
    {
      "key": { "product": 1 }
    },
    { "name": "name_index" }
    ]
  }
)

but base on page https://docs.mongodb.com/manual/reference/command/createIndexes/
the correct syntax should be like below:


db.runCommand(
  { "createIndexes": "<collection name>" },
  { "indexes": [
    {
      "key": { "product": 1 },
      "name": "name_index" 
    }
    ]
  }
)

please take a look.

Thanks,
Junlei

Hi @Junlei_Li,

Thanks for surfacing this out! We appreciate your feedback and suggestions! :sparkles:

The correct format will be as follows:

 db.runCommand({
    "createIndexes":"<collection_name>",
        "indexes":[
           {
              "key":{
                 "product": 1
              },
              "name":"name_index"
           }
        ]
     })

We will look into this and will update the lecture notes!

Regards,
Kushagra

1 Like