marcesher / cfmongodb

MongoDB client wrapper for ColdFusion
89 stars 34 forks source link

Proposed Change to Mongo.getDBCollection() To Support Using Multiple Databases #35

Closed sjdaniels closed 11 years ago

sjdaniels commented 11 years ago

I am working on an application that uses several separate Mongo databases. I would like to be able interact with all of these databases using a single Mongo connection in my application. I'm currently doing this by using the underlying java objects:

getMongoDB().getSisterDB("myotherdb").getCollection("collectionName")

But of course this means I need to interact with collections from the sister DBs differently than I do the main connection DB. I would like to be able to use the cfmongodb DBCollection object for these as well.

What I was thinking was to add an optional second argument dbName to Mongo.getDBCollection() which would return a DBCollection object pointing to the sister database collection:

Mongo.getDBCollection("collectionName","dbName");

Does this seem like a reasonable approach? Is there something I'm missing that would allow me to do this already?

sjdaniels commented 11 years ago

This is my rough implementation: https://github.com/cfrockstar/cfmongodb/commit/f7de6e5bfc75c8c5232c82efcf04fe3694f654c0

sjdaniels commented 11 years ago

Pull request sent