relation: add `scope._target` for `hasOne`

Add `_target` property to the scope method created by `hasOne`
relationship. The `_target` property is used by loopback-sdk-angular.
This commit is contained in:
Miroslav Bajtoš 2014-07-24 19:52:55 +02:00
parent e8863db928
commit cd4dba79dc
2 changed files with 4 additions and 0 deletions

View File

@ -1055,6 +1055,7 @@ RelationDefinition.hasOne = function (modelFrom, modelTo, params) {
var relationMethod = relation.related.bind(relation)
relationMethod.create = relation.create.bind(relation);
relationMethod.build = relation.build.bind(relation);
relationMethod._targetClass = relationDef.modelTo.modelName;
return relationMethod;
}
});

View File

@ -658,6 +658,9 @@ describe('relations', function () {
});
});
it('should set targetClass on scope property', function() {
should.equal(Supplier.prototype.account._targetClass, 'Account');
});
});
describe('hasAndBelongsToMany', function () {