See existing indexes in MongoDB using mongoid

我只是一个虾纸丫 提交于 2019-12-18 12:24:05

问题


I'd like to see the existing indexes used by MongoDB. Can I do the equivalent of

$ mongod
> use my_db
> db.system.indexes.find()

using Mongoid?

$ rails console
> ?

Would be convenient from my heroku apps using MongoHQ. Thanks!


回答1:


You can get at the underlying indexes for a Mongoid model through its collection.

> YourModel.collection.indexes

This reaches down into the moped driver (in Mongoid 3). See http://mongoid.org/en/moped/docs/driver.html



来源:https://stackoverflow.com/questions/12193591/see-existing-indexes-in-mongodb-using-mongoid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!