Remote Database has the same collection name

Hey mstanton,
Yeah after digging through the Meteor source code I was able to pull down the Meteor.users collection from another database like so.

Basically after you have a
var remote = ‘mongoURL’;
database = new MongoInternals.RemoteCollectionDriver(remote);

You can perform database operations with your database object, like so.

database.mongo.findOne(‘users’, “selector_object”)

An example might be

database.mongo.findOne(‘users’, {emails : {$elemMatch : {address : “email_string”} } } )

In other words, the database connection exposes a “mongo” object which you can then call normal “find”, “findOne” methods on.

The only difference between these “find”, “findOne” methods is that you need to supply the mongodb collection name as the first argument (as a string).

Don’t ask how many hours it took to figure that one out.

If that doesn’t make any sense feel free to holla back on this thread or shoot me a ring 267 992 4035. I’d be glad to help someone not waste a bunch of time.

–Dan Crescimanno