Fix #623 - use actual id order

This commit is contained in:
Fabien Franzen 2015-06-30 20:48:09 +02:00
parent ec81f20178
commit ef2555ce4e
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) {