Dynamically connecting to a database in Sails Js

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

+6
source share
1 answer

Perhaps you could change the global sails.config.connections structure and modify the existing connection. Of course, this will only continue until the application is restarted.

If you want to make it more persistent, but not change the js configuration files, you could save the connection data to localdb (sails to disk?) And re-set the connection properties (read from local db) on the sail lift using config / bootstrap. js

+2
source

Source: https://habr.com/ru/post/986783/


All Articles