I’m having some issues trying to access a collection that is named the same, but in different databases.
I’ve read a lot and it seems that there is _supressSameNameError setting that I can pass to the collection parameters, but it’s just not working correctly.
I have a collection on a remote server called ‘users’. It’s a collection that is managed by a different application altogether - not a Meteor app. I need to read this collection.
In my Meteor app, I’m using the accounts package and I’ve reassigned the ‘users’ collection by doing a Meteor.users = Account.users. I’ve also defined two remote databases (I’m not using anything local). Code example below:
var driver = new MongoInternals.RemoteCollectionDriver(
mongoURL, {
oplogUrl: oplogURL
});
var options = {
_driver: driver,
_suppressSameNameError: true
};
var driver2 = new MongoInternals.RemoteCollectionDriver(
mongoURL2, {
oplogUrl: oplogURL2
});
var options2 = {
_driver: driver2,
_suppressSameNameError: true
};
Accounts.users = new Mongo.Collection('portalusers', options);
Meteor.users = Account.users;
var SSOUsers = new Mongo.Collection('users', options2); <--This is where I get the error, even though there is no other 'users' collection defined anywhere.
When I start up Meteor, I get the ‘There is already a collection named “users”’ error in the console and the app won’t run.
I was under the assumption that the _supressSameNameError flag in the Mongo.Collections options would suppress/bypass this error message and let the app run.
As a test, I tried defining a different collection thinking it was an issue with the 'user’s collection.
var T1 = new Mongo.Collection('test', options);
var T2 = new Mongo.Collection('test', options2);
But the same error was thrown - indicating that there was already a collection named test.
I’m on Meteor 1.5.2.2
Any suggestions? Am I doing something wrong with the flag?