Hi I am looking to implement waterline and struggling to find the most efficient way of implementing this with my express application.
I want to avoid modifying the app or req objects as:
My controllers don't have access to the app object
Introduces tight coupling between modules
I currently manage my database connection like so with mongoose:
var mongoose = require('mongoose');
mongoose.connect(config.get('dbURI'));
mongoose.connection.on('error', function (err) {
logger.error('database connection error', arguments);
});
mongoose.connection.on('open', function () {
logger.log('Connected to the database');
});
Then in any of my controllers I simply just require my mongoose models.
Is there a way I can take a similar approach?
Or am I forced to initialize before I start listening for requests since the initialize step is asynchronous?
Hi I am looking to implement waterline and struggling to find the most efficient way of implementing this with my express application.
I want to avoid modifying the app or req objects as:
I currently manage my database connection like so with mongoose:
Then in any of my controllers I simply just require my mongoose models.
Is there a way I can take a similar approach?
Or am I forced to initialize before I start listening for requests since the initialize step is asynchronous?