Reputation: 65
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.
Upvotes: 6
Views: 1060
Reputation: 6304
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
Upvotes: 2