ModuleTwo.js
exports.getNotificatiosById = function (notificationId) {
db.get(notificationId, function (err, doc) {
if(!err){
return true;
}
});
};
在 modulelOne 中,我需要获取 moduleTwo 方法的结果。如果 moduleTwo 方法没有数据库查询功能,则意味着我可以在 moduleOne 中获得该方法的结果,如下所示
var res=require('./lib/moduleTwo').getNotificatiosById;
如果该 db.get 方法具有同步方法,则意味着我可以像这样进行查询
db.getSync(id);
有没有其他方法可以得到我的 moduleTwo 方法的结果。现在我正在尝试如下。是否正确
moduleOne.js
var moduleTwo=require('./lib/moduleTwo');
moduleTwo.getNotificatiosById(id,function(err,res){
if(!err){
console.log('Result of the 2nd module is '+res);
}
});