- 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})
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?
June 25, 2021June 25, 2021
0 Comment