## **创建格式:** ``` db.collection.createIndex() ``` ## **案例演示:** ``` db.accountsWithIndex.insertMany([ {name:"alice",balance:50,currency:["GBP","USD"]}, {name:"BOB",balance:150,currency:["AUD","USD"]}, {name:"BOB",balance:160,currency:["CNY","USD"]}, ]) ``` ## **创建一个索引** ``` db.accountsWithIndex.createIndex({name:1}) ``` ## **查找索引** ``` db.accountsWithIndex.getIndexes() 返回数据: { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" }, { "v" : 2, "key" : { "name" : 1 }, "name" : "name_1" } ] ```