Navigation
This version has reached end of life on October 2016. Learn more about upgrading your version of MongoDB.

db.collection.createIndex()

On this page

Definition

db.collection.createIndex(keys, options)

Creates indexes on collections.

Parameter Type Description
keys document For each field to index, a key-value pair with the field and the index order: 1 for ascending or -1 for descending.
options document Optional. One or more key-value pairs that specify index options. For a list of options, see db.collection.ensureIndex().