From ad83c82ebcb32ac5614740772d3f8d175ea3c930 Mon Sep 17 00:00:00 2001 From: Satyadeep Date: Wed, 19 Aug 2015 22:34:16 +0530 Subject: [PATCH] Fixed ReferencesMany .findById to check the given id in the ids array of the model instance --- lib/relation-definition.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/relation-definition.js b/lib/relation-definition.js index c08f12f9..48c8254a 100644 --- a/lib/relation-definition.js +++ b/lib/relation-definition.js @@ -2985,7 +2985,7 @@ ReferencesMany.prototype.findById = function (fkId, options, cb) { fkId = fkId.toString(); // mongodb } - var ids = [fkId]; + var ids = modelInstance[fk] || []; var filter = {}; @@ -2993,7 +2993,7 @@ ReferencesMany.prototype.findById = function (fkId, options, cb) { cb = cb || utils.createPromiseCallback(); - modelTo.findByIds(ids, filter, options, function (err, instances) { + modelTo.findByIds([fkId], filter, options, function (err, instances) { if (err) { return cb(err); }