Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: fix #34, Model.count 的时候,在 callback 函数里面 throw Error 会触发两次 callback
 该段代码会被多次触发
  • Loading branch information
XadillaX committed Jan 17, 2016
1 parent 57daa41 commit e567060
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/query.js
Expand Up @@ -714,13 +714,13 @@ Query.prototype.count = function(callback) {
return promisor._onExecuteResult(err);
}

try {
callback(undefined, result[0]["COUNT(0)"]);
promisor._onExecuteResult(undefined, result[0]["COUNT(0)"]);
} catch(e) {
callback(undefined, 0);
promisor._onExecuteResult(undefined, 0);
var count = 0;
if(result && result[0]) {
count = parseInt(result[0]["COUNT(0)"]) || 0;
}

callback(undefined, result[0]["COUNT(0)"]);
promisor._onExecuteResult(undefined, result[0]["COUNT(0)"]);
});

return promisor;
Expand Down

0 comments on commit e567060

Please sign in to comment.