whats up?
I have this struct in my project: https://i.stack.imgur.com/kKmkw.jpg
I have the file database.js which is some connection methods. (https://github.com/viniciusmurad/genericProject-node/blob/master/config/database.js)
In my server.js file I have a request from the database.
require('./config/database')('localhost/generic');
My question:
I'm wanting to create an auxiliary database for testing. I'm using gulp task to start mocha
gulp.task('test', function() {
env({vars: {ENV:'Test'}});
gulp.src('test/*.js', {read: false})
.pipe(gulpMocha({reporter: 'nyan' }))
})
I thought of something:
var db;
if(process.env.ENV == 'Test') {
db = mongoose.connect('localhost/generic_test');
}
else {
db = mongoose.connect('localhost/generic');
}
But where should I put the above function in accordance with the structure of my project?
Thankss