Fixed empty objList in linkOneToMany fn (#1287)
This commit is contained in:
parent
93b89f3a51
commit
cbb3f6f98a
|
@ -680,6 +680,7 @@ Inclusion.include = function(objects, include, options, cb) {
|
||||||
async.each(targets, linkOneToMany, next);
|
async.each(targets, linkOneToMany, next);
|
||||||
function linkOneToMany(target, next) {
|
function linkOneToMany(target, next) {
|
||||||
var objList = targetObjsMap[target[relation.keyTo].toString()];
|
var objList = targetObjsMap[target[relation.keyTo].toString()];
|
||||||
|
if (!objList) return next();
|
||||||
async.each(objList, function(obj, next) {
|
async.each(objList, function(obj, next) {
|
||||||
if (!obj) return next();
|
if (!obj) return next();
|
||||||
obj.__cachedRelations[relationName] = target;
|
obj.__cachedRelations[relationName] = target;
|
||||||
|
@ -810,6 +811,7 @@ Inclusion.include = function(objects, include, options, cb) {
|
||||||
function linkOneToMany(target, next) {
|
function linkOneToMany(target, next) {
|
||||||
var targetId = target[relation.keyTo];
|
var targetId = target[relation.keyTo];
|
||||||
var objList = objTargetIdMap[targetId.toString()];
|
var objList = objTargetIdMap[targetId.toString()];
|
||||||
|
if (!objList) return next();
|
||||||
async.each(objList, function(obj, next) {
|
async.each(objList, function(obj, next) {
|
||||||
if (!obj) return next();
|
if (!obj) return next();
|
||||||
obj.__cachedRelations[relationName] = target;
|
obj.__cachedRelations[relationName] = target;
|
||||||
|
@ -927,4 +929,3 @@ Inclusion.include = function(objects, include, options, cb) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue