You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am current managing a project in which there is a single instance of Loopback application but each Model must have a different datasource based on the current client that is using an application.
E.g. CLIENT 1
client: jack.it
dbname: jack
CLIENT 2
client: paul.it
dbname: paul
I have a single model defined with a default datasource that is commons for each client, except for the dbName that changes dinamically.
So, for example, I could have a model named model1 that the first time has to execute an operation on db jack and the same model the second time has to execute an operation on db paul.
Now. I have implemented a dsChanger that, based on the clientId it creates a new db if it is not already present in the dbCache of mongodb and return the instance of the new db object, something like that:
Hi everyone,
I am current managing a project in which there is a single instance of Loopback application but each Model must have a different datasource based on the current client that is using an application.
E.g.
CLIENT 1
client: jack.it
dbname: jack
CLIENT 2
client: paul.it
dbname: paul
I have a single model defined with a default datasource that is commons for each client, except for the dbName that changes dinamically.
So, for example, I could have a model named model1 that the first time has to execute an operation on db jack and the same model the second time has to execute an operation on db paul.
Now. I have implemented a dsChanger that, based on the clientId it creates a new db if it is not already present in the dbCache of mongodb and return the instance of the new db object, something like that:
I want to modify the collection function to take as second param the db instance, but I don't really like this solution.
What is the best practice to do this (change dinamically the db) without break the connector logic?
Thank you in advance.
The text was updated successfully, but these errors were encountered: