Really? is this documented anywhere?
Got an example?
I’ve spent ages trying to get this to work and utterly failed, so became convinced it’s not possible.
The docs explicitly say the way to do it is to comment out the bits from config/onnections.js you don’t want - which is entirely unsatisfactory.
Note If any connection to an adapter is used by a model, then all connections to that adapter will be loaded on sails.lift
, whether or not models are actually using them. In the example above, if a model was configured to use the localMysql
connection, then both localMysql
and remoteMysql
would attempt to connect at run time. It is therefore good practice to comment out any connection configurations that you aren't using!
So even if i specify my test db connection in config/env/test.js (which FYI is conspicuously absent from the documentation on config/env, much like any mention of how to test sails apps) and a dev db in config/env/development.js - the fact that I have both test, dev and production connection configs in config/connections.js means that my app will attempt to connect to all three of them. And when that fails because in my production environment there are no development or test databases my app fails.
This, to me, seems like such a commonplace use-case, I am surprised it’s not explicitly documented or catered for.
D