Assuming you have customers collection with a firstName and lastName field, which is the correct MongoDB shell command to create an index on lastName, then firstName both ascending?

  • db.customers.createIndex(“lastName, firstName, ASC”)
  •  db.customers.addIndex({lastName:”ASC”, firstName: “ASC”})
  •  db.customers.newIndex({lastName:1, firstName:1})
  •  db.customers.createIndex({lastName:1, firstName: 1})

Leave a Reply

Your email address will not be published. Required fields are marked *