This fixes the apparent scope and comparison issues when calling a foreign key relation.
This commit is contained in:
parent
cdd328c902
commit
cba174b4ff
|
@ -946,7 +946,7 @@ AbstractClass.belongsTo = function (anotherClass, params) {
|
|||
anotherClass.find(id, function (err,inst) {
|
||||
if (err) return cb(err);
|
||||
if (!inst) return cb(null, null);
|
||||
if (inst[fk] === this.id) {
|
||||
if (inst.id === this[fk]) {
|
||||
cb(null, inst);
|
||||
} else {
|
||||
cb(new Error('Permission denied'));
|
||||
|
@ -971,12 +971,12 @@ AbstractClass.belongsTo = function (anotherClass, params) {
|
|||
this.__cachedRelations[methodName] = p;
|
||||
} else if (typeof p === 'function') { // acts as async getter
|
||||
if (typeof cachedValue === 'undefined') {
|
||||
this.__finders__[methodName](this[fk], function(err, inst) {
|
||||
this.__finders__[methodName].apply(self, [this[fk], function(err, inst) {
|
||||
if (!err) {
|
||||
self.__cachedRelations[methodName] = inst;
|
||||
}
|
||||
p(err, inst);
|
||||
});
|
||||
}]);
|
||||
return this[fk];
|
||||
} else {
|
||||
p(null, cachedValue);
|
||||
|
|
Loading…
Reference in New Issue