On this page
db.collection.ensureIndex()
在本页面
Definition
db.collection.
ensureIndex
(键,选项)- 从 3.0.0 版开始不推荐使用:db.collection.ensureIndex()现在是db.collection.createIndex()的别名。
如果索引不存在,则在指定字段上创建索引。
Additional Information
使用db.collection.createIndex()而不是db.collection.ensureIndex()创建新索引。
本手册的Indexes部分提供了 MongoDB 中索引和索引的完整文档。
db.collection.getIndexes()查看集合的现有索引的规范。