Assume this simple module:
var mongoose = require('mongoose-util');
mongoose.myOwnCreateConnection(function(err, connection) {
if(err) {
console.log('log error somehow and make it die');
module.exports = null;
} else {
module.exports = connection;
}
});
It won't work obviously, but how to manage that calls in context module initialization? What is the best practice here? Do I need to use function declaration only in module init? Thanks in advance. I am asking because express has app module where everything is initialized.
createConnectiondoesn't take a function as its argument: mongoosejs.com/docs/api.html#index_Mongoose-createConnection