- Reference >
mongoShell Methods >- Collection Methods >
- db.collection.createIndex()
db.collection.createIndex()¶
On this page
Definition¶
-
db.collection.createIndex(keys, options)¶ Creates indexes on collections.
Parameter Type Description keysdocument For each field to index, a key-value pair with the field and the index order: 1for ascending or-1for descending.optionsdocument Optional. One or more key-value pairs that specify index options. For a list of options, see db.collection.ensureIndex().