Reputation: 14260
I currently assign a mongodb to my meteor app using the env variable "MONGO_URL": "mongodb://localhost:27017/dbName" when I start the meteor instance.
So all data gets written to the mongo database with the name "dbName". I am looking for a way to individually set the dbName for each custumer upon login in order to seperate their data into different databases.
Upvotes: 2
Views: 846
Reputation: 20256
Here's another approach that will make your life eternally easier:
nginx might help you with the above.
It is generally good practice to run separate DBs when offering a B2B solution.
That's a matter of opinion that depends heavily on the platform. Many SaaS providers would argue that point.
Upvotes: 0
Reputation: 2010
This generally unsupported as this is defined at startup. However, this thread offers a possible solution:
https://forums.meteor.com/t/switch-database-while-meteor-is-running/4361/6
var database = new MongoInternals.RemoteCollectionDriver("<mongo url>");
MyCollection = new Mongo.Collection("collection_name", { _driver: database });
This would allow you to define the database name in the mongo url but would require a fair bit of extra work to redefine your collections on a customer by customer basis.
Upvotes: 1