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:
parent
e8863db928
commit
cd4dba79dc
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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 () {
|
||||
|
|
Loading…
Reference in New Issue