Merge pull request #648 from fabien/fix/references-many-include

Fix #623 - use actual array order for referencesMany include handling.
This commit is contained in:
Fabien Franzen 2015-07-01 14:02:16 +02:00
commit 72897c9f1a
1 changed files with 2 additions and 0 deletions

View File

@ -407,6 +407,7 @@ Inclusion.include = function (objects, include, options, cb) {
* @param callback
*/
function includeReferencesMany(callback) {
var modelToIdName = idName(relation.modelTo);
var allTargetIds = [];
//Map for Indexing objects by their id for faster retrieval
var targetObjsMap = {};
@ -461,6 +462,7 @@ Inclusion.include = function (objects, include, options, cb) {
relation.modelTo.include(targets, subInclude, options, next);
});
}
targets = utils.sortObjectsByIds(modelToIdName, allTargetIds, targets);
//process each target object
tasks.push(targetLinkingTask);
function targetLinkingTask(next) {