From 83508afc5e33c055c1ecc4d37bd8f06d1998b2a9 Mon Sep 17 00:00:00 2001 From: tan4eto86 Date: Thu, 5 Sep 2013 16:03:24 +0300 Subject: [PATCH] Update hasmany association with through option to work when one of instances has more than one mapped instanses of the second model. --- lib/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index f1170d1b..3330ba68 100644 --- a/lib/index.js +++ b/lib/index.js @@ -284,13 +284,14 @@ utils.mixin(model, new (function () { if (assnType == 'hasMany') { idParam = []; data.forEach(function (item) { - idParam.push(item[idColName]); + idParam.push({id: item[idColName]}); }); + query.or = idParam; } else { idParam = item[idColName]; + query.id = idParam; } - query.id = idParam; model[modelName][queryName](query, opts, callback); }); }