How to programmatically get the current database Mongoid is writing to?

前端 未结 5 1681
南笙
南笙 2021-02-13 15:22

I am talking to multiple databases using Mongoid.override_database(\"database_name\") using Mongoid with rails. How do I find the current database programmatically?

Mon

5条回答
  •  误落风尘
    2021-02-13 16:16

    The new way to get this is

    Mongoid::Config.clients["default"]["database"]
    

    You can also just have a look at

    Mongoid::Config.clients
    

    to see what else is available.

提交回复
热议问题