loopbackjs - How to configure two different datasource for a model in Strongloop Loopback framework? -


our mysql database set write clusters , read clusters, there way set strongloop loopback model (e.g. user) write mysql host , read mysql host b?

try use attachto() if want change datasource single model. example

app.models.yourmodel.attachto(app.datasources.readds); readdata(); ... app.models.yourmodel.attachto(app.datasources.writeds); writedata(); 

you have define readds , writeds datasources in datasources.json file:

{  "readds": {     "host": "hosta",         "database": "dbonhosta",     "username": "user",     "password": "password",     "name": "readds",     "connector": "mysql"   },   "writeds": {     "host": "hostb",     "database": "dbonhostb",     "username": "user",     "password": "password",     "name": "writeds",     "connector": "mysql"   } } 

or can create datasources dynamically.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -