MongoMapper and more than one databases in application

风格不统一 提交于 2019-12-10 11:46:10

问题


Is it possible to use MongoMapper in application that stores its models in many databases? For example I have separated database for Users and another one for Orders and I want to model both User and Order using MongoMapper. Of course I can switch MongoMapper.connection attribute but it is potentially unsafe due to race condition.


回答1:


You can set the connection per model:

User.connection(Mongo::Connection.new('localhost', 27017))



来源:https://stackoverflow.com/questions/6751568/mongomapper-and-more-than-one-databases-in-application

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