Fix error handling

This commit is contained in:
Raymond Feng 2015-07-29 10:21:47 -07:00
parent b7042b982f
commit 4d7bfc94cd
1 changed files with 6 additions and 5 deletions

View File

@ -1382,7 +1382,7 @@ DataAccessObject.find = function find(query, options, cb) {
var allCb = function(err, data) { var allCb = function(err, data) {
var results = []; var results = [];
if (Array.isArray(data)) { if (!err && Array.isArray(data)) {
async.each(data, function(item, callback) { async.each(data, function(item, callback) {
var d = item;//data[i]; var d = item;//data[i];
var Model = self.lookupModel(d); var Model = self.lookupModel(d);
@ -1434,7 +1434,7 @@ DataAccessObject.find = function find(query, options, cb) {
callback(); callback();
}); });
} }
}, },
function(err) { function(err) {
if (err) return cb(err); if (err) return cb(err);
@ -1448,8 +1448,9 @@ DataAccessObject.find = function find(query, options, cb) {
cb(err, results); cb(err, results);
}); });
} }
else else {
cb(err, []); cb(err, data || []);
}
}; };
if (options.notify === false) { if (options.notify === false) {
@ -2370,7 +2371,7 @@ DataAccessObject.prototype.updateAttributes = function updateAttributes(data, op
return; return;
} else if (strict === 'validate') { } else if (strict === 'validate') {
inst.__unknownProperties.push(key); inst.__unknownProperties.push(key);
} }
} }
data = removeUndefined(result); data = removeUndefined(result);
} }