Same collection name in multiple DBs. How do I connect to them?

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)


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 });

You could publish your data under a new collection name but in short, no, there is no simple way to just connect to a different database in the client, in the client we always have just one Minimongo.

I see. Would it be possible to merge all the different collections into a single collection in minimongo somehow? There by there will still be a single collection on the client?

I don’t think this is a good idea.

Meteor does a lot of state management to you in order to avoid duplications and other things on Minimongo, if you mix collections there it would probably break many logics.

Couldn’t you rename your collections?

I see. I suppose I’ll live with subscriptions under different names.

Can’t really rename the collections as the database is owned by a different service. I only need to show some docs on the UI as part of some control mechanism. Given that there are only a handful of docs, it should not be too much of a bother.