mongodb 索引创建
2022/4/3 19:19:41
本文主要是介绍mongodb 索引创建,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1. 多键唯一索引
a.loc 和 a.qty 为符合多键索引
db.collection.createIndex( { "a.loc": 1, "a.qty": 1 }, { unique: true } )
如:
db.getCollection("Name,idcardNo").createIndex( { "Name": 1, "idcardNo": 1 }, { unique: true } )
2 单字段唯一索引
db.members.createIndex( { "user_id": 1 }, { unique: true } )
3 普通索引
db.collection.createIndex( { name: -1 } )
这篇关于mongodb 索引创建的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26解决google chrome helper 内存占用较高!
- 2024-04-01got an unexpected keyword argument
- 2024-03-30维多利亚的秘密 golang入坑系统
- 2024-03-29mongodb sort by date
- 2024-03-29go swagger
- 2024-03-25mongodb cdc
- 2024-03-25how to use go in vscode
- 2024-03-22mongooseserverselectionerror: connect econnrefused ::1:27017
- 2024-03-21pymongo insert_many
- 2024-03-18projection mongodb