db.collection.createIndex()

db.collection.createIndex(keys, options)

1.8 版后已移除.

参数:
  • keys (document) – A document that contains pairs with the name of the field or fields to index and order of the index. A 1 specifies ascending and a -1 specifies descending.
  • options (document) – A document that controls the creation of the index. This argument is optional.

The ensureIndex() method is the preferred way to create indexes on collections.

MongoDB Manual (Index)

关于

生态系统

格式

资源