mzaj
mzaj

Reputation: 85

MongoMapper and more than one databases in application

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.

Upvotes: 1

Views: 405

Answers (1)

Brian Hempel
Brian Hempel

Reputation: 9094

You can set the connection per model:

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

Upvotes: 1

Related Questions