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 })

results matching ""

    No results matching ""