Handle hasMany.though

This commit is contained in:
Raymond Feng 2014-01-28 17:59:59 -08:00
parent 3b6070fe58
commit 43637a690d
1 changed files with 17 additions and 11 deletions

View File

@ -543,8 +543,12 @@ DataAccessObject.find = function find(params, cb) {
obj._initProperties(d, false, params.fields);
if (params && params.include) {
if (params.collect) {
// Return the collected item for through models
obj = obj.__cachedRelations[params.collect];
} else {
// Try to normalize the include
var includes = params.include;
var includes = params.include || [];
if (typeof includes === 'string') {
includes = [includes];
} else if (typeof includes === 'object') {
@ -556,8 +560,10 @@ DataAccessObject.find = function find(params, cb) {
});
delete obj.__data.__cachedRelations;
}
}
data[i] = obj;
});
if (data && data.countBeforeLimit) {
data.countBeforeLimit = data.countBeforeLimit;
}