Navigation
This version of the documentation is archived and no longer supported.

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().