Currently I'm setting my client connection for node-mysql
by doing the following in my app.js
and a special config/environment.js
:
var client = mysql.createClient({
user: 'USER',
database: 'DATABASE',
password: 'PASSWORD',
host: 'HOST'
});
app.configure(function(){
...
app.set('client', client);
...
});
Then in my client code I just call app.settings.client
to use the MySQL client.
I'm not sure if this is the right approach, and it certainly doesn't work when I'm doing testing, as I need a running instance of the app.
Any suggestions?