本文共 621 字,大约阅读时间需要 2 分钟。
mongodb的索引的创建方法;
db.collection.ensureIndex(keys,options) 在mongodb3.0版本后被弃用。
现在是db.collection.createIndex()的别名
db.colleciton.getIndexes()得到collection的所有的索引 () 只能在3.0版本用
For MongoDB 3.0 deployments using the storage engine, if you rundb.collection.getIndexes() from a version of the shell before 3.0 or a version of the driver prior to , db.collection.getIndexes() will return no data, even if there are existing indexes. For more information, see .
得到collection的所有索引:
db.people.getIndexes()
To return a list of all indexes on all collections in a database, usethe following operation in the shell:
db.system.indexes.find()
转载地址:http://aodli.baihongyu.com/