From b4b1c784dda213825f57b35012ce94108538a8cd Mon Sep 17 00:00:00 2001 From: Fabien Franzen Date: Sat, 16 Aug 2014 13:04:13 +0200 Subject: [PATCH] HasMany exists should use internal findById This limits the scope correctly, taking polymorphics into account. (the foreign key check is actually obsolete I think) --- lib/relation-definition.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/relation-definition.js b/lib/relation-definition.js index e11b28bc..304ed782 100644 --- a/lib/relation-definition.js +++ b/lib/relation-definition.js @@ -692,12 +692,11 @@ HasMany.prototype.findById = function (fkId, cb) { * @param {Function} cb The callback function */ HasMany.prototype.exists = function (fkId, cb) { - var modelTo = this.definition.modelTo; var fk = this.definition.keyTo; var pk = this.definition.keyFrom; var modelInstance = this.modelInstance; - modelTo.findById(fkId, function (err, inst) { + this.findById(fkId, function (err, inst) { if (err) { return cb(err); }