Skip to content

Latest commit

 

History

History
28 lines (17 loc) · 662 Bytes

createIndex.md

File metadata and controls

28 lines (17 loc) · 662 Bytes

collection.createIndex

Mongo documentation

Creates an index on the db and collection (will not create if already exists)

Arguments

  1. fieldOrSpec (String|Array|Object): Defines the index.

  2. [options] (object)

  3. [callback] (function)

Returns

A promise

Example

users.createIndex('name.first')
users.createIndex('name last')
users.createIndex(['nombre', 'apellido'])
users.createIndex({ up: 1, down: -1 })
users.createIndex({ woot: 1 }, { unique: true })