Question: 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})`
Answer: The correct answer of the above question is Option D:`db.customers.createIndex({lastName:1, firstName: 1})`