I have a meteor app that connects to multiple DBs. However, there are certain DBs that contain the same collection name. I’m unable to declare thosecollections since meteor cribs if it notices the same collection name again. Is there a workaround for this? There is a similar post but has anything changed since?
Initializing external DBs:
Meteor.startup(function () {
const externalDBList = (Meteor.isProduction && process.env.DB_LIST.split(",")) || (Meteor.isDevelopment && Meteor.settings.private.DB_LIST);
externalDBDrivers = {};
for (let DB of externalDBList) {
externalDBDrivers[DB] = new MongoInternals.RemoteCollectionDriver(externalDBURL);
}
});
td1 = new Mongo.Collection("Plugins", { _driver: externalDBDrivers["tdb"] }); // Plugins is the name of a collection present in threats-database
However when I try to declare another “Plugins” collection from another database, meteor errors.
W20210923-12:59:31.463(5.5)? (STDERR) Error: There is already a collection named "Plugins"
W20210923-12:59:31.463(5.5)? (STDERR) at new Collection (packages/mongo/collection.js:122:15)
–
UPDATE
Contrary to the linked post, I was able to get the second collection name working on the server side when I passed the _suppressSameNameError: true
parameter.
However, I’m unable to do this on the client side. Is there a way to let the client know that this collection is different from the collection it previously saw? There is no way for met to do the below on the client:
td1 = new Mongo.Collection("Plugins", { _driver: externalDBDrivers["tdb"], _suppressSameNameError: true });