我想知道你是否可以帮我解决我的问题。我的代码是:
test = function (_mappedReq, _callback, _req, _res, _session){
_mappedReq.created_at = new Date();
nbConnSaveCallback =0;
connectDB().database("users").save(_mappedReq, function (err, res) {
nbConnSaveCallback +=1;
logger.debug("nbConnSaveCallback="+ nbConnSaveCallback);
if(err){
logger.minor("Error while trying to save " + s.doc._id, lambda);
_callback(err, null);
}else{
logger.debug("Succeed to save);
console.log("res._id = " + res._id );
_callback(null, res);
}});
}
connectDB = connectDB = function(){
if(_.isEmpty(this.dbConnexion)){
logger.info('Opening connexion to couchDB');
this.dbConnexion = new cradle.Connection(this.config.db.url, this.config.db.port, {
auth: { username: this.config.db.username, password: this.config.db.password },
cache:false
});
}
return this.dbConnexion
}
当我进入高频呼叫测试功能时,nbConnSaveCallback的结果是> 1?
你知道可以追加什么吗?
的问候,
答案 0 :(得分:0)
为了回答我的问题,我必须把'var'放在nbConnSaveCallback = 0之前;
问候,