Community Forum Friday Jan 16th 11:00 am CST on Hangout

328 views
Skip to first unread message

Courtney Wyrtzen

unread,
Jan 14, 2015, 12:48:48 PM1/14/15
to sai...@googlegroups.com
Mike H will facilitate - what are ya'll curious about right now?

http://goo.gl/Js1HP7

Courtney Wyrtzen

unread,
Jan 15, 2015, 10:24:16 AM1/15/15
to sai...@googlegroups.com
Hi Friends, This is THE REAL link to the Community Hangout: https://plus.google.com/events/cejeiik709kvk9aeo7pqtg5embk - - see ya'll tomorrow, Friday January 16th 11:00 am CST


Dave Sag

unread,
Jan 15, 2015, 2:54:15 PM1/15/15
to sai...@googlegroups.com
Yay 4am on Saturday my time.

What I'd like an answer to is how to configure Sails to use a test DB vs a development DB vs a production DB without the lifter trying to connect to ALL of the databases specified in the connections.js file, and without having to comment out the code I don't need in each environment (as per the docs) as, frankly, that's stupid.  Trying to work this out has stalled my project so much I am considering abandoning Sails completely., and I'd rather not do that.

Rob Wormald

unread,
Jan 15, 2015, 3:25:02 PM1/15/15
to Dave Sag, sai...@googlegroups.com
It already does this. Add the connection configs to your environments (config/env)

Sent from my iPhone

Dave Sag

unread,
Jan 15, 2015, 5:36:09 PM1/15/15
to sai...@googlegroups.com, Rob Wormald
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
signature.asc

Andrej Gerbec

unread,
Jan 21, 2015, 5:03:53 AM1/21/15
to sai...@googlegroups.com, rob.w...@innitapps.com
Yes, the docs could be more up-to-date and noob-point-of-view oriented... But feel free to contribute, I guess. Anyway, your problem should not be too hard to solve. You have to tell node which environment you're at when starting the process:

NODE_ENV=production sails lift

Then you can access the value form within sails as process.env.NODE_ENV and act accordingly...

Dave Sag

unread,
Jan 21, 2015, 6:07:07 AM1/21/15
to Andrej Gerbec, sai...@googlegroups.com, rob.w...@innitapps.com
Thanks. I'll try not to feel insulted by the term "noob" there. Yes the docs need updating as they are out and out misleading. 

Fortunately someone replied off-list and explained where I was going wrong, gave me some constructive advice, and my project is back on track. And, nicely, he didn't assume that I'm a total idiot either. 

Cheers

Dave

Sent from my iPhone

Andrej Gerbec

unread,
Jan 21, 2015, 6:51:24 AM1/21/15
to sai...@googlegroups.com, andrej...@gmail.com, rob.w...@innitapps.com
I assure you the "noob" was not aimed at you. I've written miles of code in my life, but still fall into the noob category when it comes to sails... Most of us are.

John Tomaselli

unread,
Apr 1, 2015, 1:49:08 PM4/1/15
to sai...@googlegroups.com, andrej...@gmail.com, rob.w...@innitapps.com
+1, I don't think anyone should get offended when someone has taken the tiime to respond, Just say'n
John
Reply all
Reply to author
Forward
0 new messages