mongodb 索引

mongodb的索引的创建方法;

db.collection.ensureIndex(keys,options) 在mongodb3.0版本后被弃用。

现在是db.collection.createIndex()的别名

db.colleciton.getIndexes()得到collection的所有的索引 () 只能在3.0版本用

For MongoDB 3.0 deployments using the WiredTiger storage engine, if you rundb.collection.getIndexes() from a version of the mongo shell before 3.0 or a version of the driver prior to 3.0 compatible version, db.collection.getIndexes() will return no data, even if there are existing indexes. For more information, see WiredTiger and Driver Version Compatibility.

得到collection的所有索引:

db.people.getIndexes()

To return a list of all indexes on all collections in a database, usethe following operation in the mongo shell:

db.system.indexes.find()

你可能感兴趣的:(mongodb 索引)