I am trying to build a multi tenant system where a code will be given to the user and then based on the code further interaction will take place with the respective database.
I looked into the following approach https://github.com/asimzsaeed/mongodb_node_multi_tenancy_startup but it has set up multiple domains and then change the global connection.
My requirement is to have a single website and then play with the db connection with the session of the user.
For example
User 1 logs in then he is assigned DB1 User 2 logs in then he is assigned DB2 User 3 logs in then he is assigned DB1 because User1 and User3 has same code.
So I want to learn how can I manage such a situation in NodeJS and MongoDB app.
Please suggest any article to read where such situation is handled. Looking forward to a positive response.