-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to dynamically connect to database in loopback #3886
Comments
Hi @rockyshukla you can take a look of the solution in #1885. |
@jannyHou I saw that solution but it does not work. let me explain this issue in detail
|
I would like to implement multitenancy in the same way. |
@cineca-catalano, no actually I did not get enough time to try but I got an idea how I can achieve that |
@rockyshukla, what happens if multiple requests of different tenant ( different database) are processed concurrently? |
@cineca-catalano yes it will processed concurrently if you found anything else please post solution here it will help other |
Hi @rockyshukla, if request 2 is made before request 1 has finished, that request 1 is made in database 2. |
@cineca-catalano can you show me your sample code so i can know you issue, did you used middleware ware ? |
@cineca-catalano did you find solution for this problem |
Hi @rockyshukla, It is not optimal for the performances, the next step is to create a connection pool for each clientId. |
@cata86 can you post some demo code (required code to switch db) it will help me as well as other and thanks for your patience |
@cata86 hi, would you like to post the solution or part of your solution? i have the same problem and i really appreciated if you could help me. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the |
Anyone found solution on this. @cata86 would you like to post the solution or part of your solution? I have the same problem and I really appreciated if you could help me. |
how I can switch database dynamically i.e connection of each database is stored in the master database. for eg:- if the user wants his database in Mumbai region then my code check whether Mumbai database exists in the master database if yes then make the connection to Mumbai database now all model should dynamically connect to Mumbai database.if not then I m passing error message that database does not exist. now problem is that my user model create method first connected to the master database and afterward it should connect to other databases if exists in master for eg:-
all other methods of user model should dynamically connect to Mumbai database how would I connect to database dynamically in above code and another thing
now ideas would be highly appreciated.
The text was updated successfully, but these errors were encountered: