MnogoDB唯一索引,稀疏索引
1,单个字段唯一索引 db.collection.createIndex({name:1},{unique:true} 2,多个字段联合索引示例 db.collection.createIndex({name_one:1,name_two:1},{unique:true}) 3,创建稀疏索引
db.collection.createIndex({ "phone": 1 }, { sparse: true })
eg:
参考文档:
https://www.jianshu.com/p/4dd08c935f00
https://www.jianshu.com/p/adedee065c28