1
假設這個簡單的模塊:異步函數結果模塊初始化
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;
}
});
它不會明顯地工作,但如何管理上下文模塊初始化調用?這裏最好的做法是什麼?我是否需要僅在模塊init中使用函數聲明?提前致謝。我問,因爲快遞有應用程序模塊,一切都初始化。
貓鼬'createConnection'並不需要一個函數作爲它的參數:http://mongoosejs.com/docs/api.html#index_Mongoose-createConnection – krl
這是不明確你在這裏試圖達到什麼 – krl
對不起,這是一個簡化,我會編輯這個荒謬的瘋狂的例子:) –