Quick multi-tenant support

21 views
Skip to first unread message

Pawan Kumar

unread,
Dec 12, 2013, 6:27:21 AM12/12/13
to scala...@googlegroups.com
Hi All

How can I pass different MongoConnection to SalatDAO depending on different tenant / customer ID?
In other words, how a tenant specific mongo db name (e.g.com.mongodb.casbah.MongoConnection()("tenant1_db") or com.mongodb.casbah.MongoConnection()("tenant2_db") etc) can be passed to SalatDAO for all CRUD operations.
I can get the tenant ID from Request object of Play 2 but not able to implicitly send the corresponding mongodb to DAOs.
Any help is appreciated.

Thanks
Pawan


Pawan Kumar

unread,
Jan 6, 2014, 1:50:18 PM1/6/14
to scala...@googlegroups.com
Anybody, how to do it?

Thanks
Pawan

rose katherine toomey

unread,
Jan 6, 2014, 2:00:45 PM1/6/14
to scala-salat
Hi Pawan,

You could copy-paste-modify ModelCompanion and change 

  def dao: DAO[ObjectType, ID]

to require an implicit database and return a new instance of a SalatDAO implementation that uses this database to get the collection.

Best,
Rose

--
You received this message because you are subscribed to the Google Groups "scala-salat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-salat...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages