我基本上有这个,这很好用:
Ideas = new Mongo.Collection('ideas', {_driver: companyDb});
上面的CompanyDb定义为:
companyDbString = 'mongodb://127.0.0.1:27017/demo';
companyDb = new MongoInternals.RemoteCollectionDriver(companyDbString);
但是,我如何更改Meteor用户集合的驱动程序。我试过这个:
Meteor.users = new Mongo.Collection('users', {_driver: companyDb});
但是它给出了预期的错误:已经有一个名为"用户"'错误。
我知道这听起来像一个奇怪的用例,但' companyDb'在我的应用程序中更改子域名。所以我基本上每个子域需要一个单独的mongo数据库
答案 0 :(得分:0)
试试这个
AnotherUsersCollection = new Mongo.Collection(“users”, { _driver: companyDb });
或
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"} } } )
courtsey Dan crescimano https://forums.meteor.com/t/remote-database-has-the-same-collection-name/7157/3