HasMany exists should use internal findById
This limits the scope correctly, taking polymorphics into account. (the foreign key check is actually obsolete I think)
This commit is contained in:
parent
855270d14a
commit
b4b1c784dd
|
@ -692,12 +692,11 @@ HasMany.prototype.findById = function (fkId, cb) {
|
||||||
* @param {Function} cb The callback function
|
* @param {Function} cb The callback function
|
||||||
*/
|
*/
|
||||||
HasMany.prototype.exists = function (fkId, cb) {
|
HasMany.prototype.exists = function (fkId, cb) {
|
||||||
var modelTo = this.definition.modelTo;
|
|
||||||
var fk = this.definition.keyTo;
|
var fk = this.definition.keyTo;
|
||||||
var pk = this.definition.keyFrom;
|
var pk = this.definition.keyFrom;
|
||||||
var modelInstance = this.modelInstance;
|
var modelInstance = this.modelInstance;
|
||||||
|
|
||||||
modelTo.findById(fkId, function (err, inst) {
|
this.findById(fkId, function (err, inst) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue