安装期间创建索引 MongoDB
我正在使用 .NET 和 MongoDB 为系统创建安装。我编写了一个批处理来确保数据库上的索引,但除非您创建了集合,否则它不会工作。这样做是不是一种不好的做法:
db.Customers.save({username:"mkyong"})
db.Customers.remove({})
db.Customers.ensureIndex({SystemId:1,CampaignId:1,LocalIdentifier:1})
I am creating an installation for a system using .NET and MongoDB. I wrote a batch to ensure indexes on DB but it would not work unless you have collection created. Is it a bad practice to do smth like:
db.Customers.save({username:"mkyong"})
db.Customers.remove({})
db.Customers.ensureIndex({SystemId:1,CampaignId:1,LocalIdentifier:1})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
createCollection
命令:Use the
createCollection
command: