MongoDb创建索引

describe

在test表下创建字段c的正序索引,提高查询效率

command

db.getCollection('test').createIndex({c:1})

parameter

createIndex(keys) :  在集合上创建索引
keys : { "$**" : 1 }升序索引, { "$**" : -1 降序索引}

running results

{
    "createdCollectionAutomatically" : false,
    "numIndexesBefore" : 10,
    "numIndexesAfter" : 11,
    "ok" : 1.0
}

I hope to help every developer quickly find the commands they need. Of course, you can also add your own commonly used commands for easy searching.