MongoDb创建多字段索引


 description

在 test 集合上 创建 name字段的正序索引和 age的倒序索引

 command

db.getCollection('test').createIndex({name:1, age:-1})

 parameter

createIndex : 在集合上创建索引

 result

{
    "createdCollectionAutomatically" : false,
    "numIndexesBefore" : 1,
    "numIndexesAfter" : 2,
    "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.