See existing indexes in MongoDB using mongoid

2019-01-17 22:16发布

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条回答
女痞
2楼-- · 2019-01-17 23:05

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

查看更多
登录 后发表回答