0
呼叫ID从MongoDB中有回调函数我需要帮助有关与MongoDB的node.js的Asynchronus电话,我需要调用同步方法进行数据
var GetID = function (nameval, callback) {
console.log(nameval);
console.log("munesh hello");
GenerateID.find({ "id_name": nameval }, {
"id_code": 1,
"id_value": 1, "_id": 0
}, function (err, genvalue) {
if (err) {
console.log('hello');
}
else {
if (genvalue === null) {
callback(err, false);
}
else {
callback(err, true);
}
}
console.log(genvalue);
});
};
的进一步处理,并调用上面的方法,所以我们需要
所以我们需要编号从GenerateID.GetID
并做我们自己的工作。
var region_id = GenerateID.GetID(name, function (error, result) {
if (error) {
console.log("getting any error");
} else {
console.log(region_id);
if (!result) {
console.log('data is not coming');
} else {
console.log('data is coming');
}
}
});
使用async.js用于控制流 –