最后更新于3年前
在本页面
db.collection. ensureIndex(键,选项)
db.collection.
ensureIndex
从3.0.0版开始不推荐使用:db.collection.ensureIndex()现在是的别名 db.collection.createIndex()。
db.collection.ensureIndex()
db.collection.createIndex()
如果索引尚不存在,则在指定字段上创建索引。
使用db.collection.createIndex()而不是db.collection.ensureIndex()来创建新索引。
本手册的索引部分用于 MongoDB 中索引和索引的完整文档。
db.collection.getIndexes()查看集合的现有索引的规范。
译者:李冠飞
校对: