From ef2555ce4e649619155a2107bda1bf836d79fce2 Mon Sep 17 00:00:00 2001 From: Fabien Franzen Date: Tue, 30 Jun 2015 20:48:09 +0200 Subject: [PATCH] Fix #623 - use actual id order --- lib/include.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/include.js b/lib/include.js index 30f14313..3841d786 100644 --- a/lib/include.js +++ b/lib/include.js @@ -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) {