Dynamic database connection in Sails Js

六月ゝ 毕业季﹏ 提交于 2019-12-08 20:52:47

问题


How I can set a database connection from a controller?. I need to specify in the controller the type of database , user, password, port, database name and set this in connections.js.


回答1:


You could probably modify the sails.config.connections global and edit an existing connection. Of course this would only last until the app is restarted.

If you want to make it more permanent but not modify config js files you could then save the connection details on a localdb (sails-disk?) and re-set the connection properties (read from local db) on sails lift using config/bootstrap.js



来源:https://stackoverflow.com/questions/30111780/dynamic-database-connection-in-sails-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!