loopbackjs - Loopback Multitenancy Database Swap -


i'd implement multitenancy in loopback app. right now, i'm trying use middleware redefine datasources point different databases on mongodb server each request, based on domain request. code runs, doesn't seem changing datasource. instead, uses 1 defined in datasources.json.

right now, doing. of models reference "my_db" , i'd have 1 database on mongo server each tenant.

var datasourceobj = {         my_db:{           url: process.env.mongolab_uri,           connector: "mongodb",           name: "my_db",           database: tenant         }       }        object.keys(datasourceobj).foreach(function(datasource) {          app.datasources[datasource].adapter.settings = datasourceobj[datasource];         app.datasources[datasource].adapter.clientconfig = datasourceobj[datasource];         app.datasources[datasource].settings = datasourceobj[datasource];         app.datasources[datasource].connector.settings = datasourceobj[datasource];         app.datasources[datasource].connector.clientconfig = datasourceobj[datasource];        }); 

does have ideas? silly way multi-tenancy?

thanks!

i make project. i'ts alternative.

https://github.com/paulomcnally/loopback-example-multitenant


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -