Fixed QuerySet.average issue that ignored 0

This commit is contained in:
Harry Marr
2010-08-30 19:48:17 +01:00
parent f1aec68f23
commit 17642c8a8c
2 changed files with 6 additions and 2 deletions

View File

@@ -892,7 +892,7 @@ class QuerySet(object):
var total = 0.0;
var num = 0;
db[collection].find(query).forEach(function(doc) {
if (doc[averageField]) {
if (doc[averageField] !== undefined) {
total += doc[averageField];
num += 1;
}