Merge pull request #3628 from strongloop/declarative-nest-remoting

Allow declarative nestRemoting for relations
This commit is contained in:
Raymond Feng 2017-09-28 11:06:32 -07:00 committed by GitHub
commit c453ad52c2
2 changed files with 8 additions and 2 deletions

View File

@ -286,6 +286,11 @@ module.exports = function(registry) {
relation.type === 'referencesMany') { relation.type === 'referencesMany') {
ModelCtor.hasManyRemoting(relationName, relation, define); ModelCtor.hasManyRemoting(relationName, relation, define);
} }
// Automatically enable nestRemoting if the flag is set to true in the
// relation options
if (relation.options && relation.options.nestRemoting) {
ModelCtor.nestRemoting(relationName);
}
} }
// handle scopes // handle scopes

View File

@ -1475,7 +1475,7 @@ describe('relations - integration', function() {
); );
app.model(Chapter, {dataSource: 'db'}); app.model(Chapter, {dataSource: 'db'});
Book.hasMany(Page); Book.hasMany(Page, {options: {nestRemoting: true}});
Book.hasMany(Chapter); Book.hasMany(Chapter);
Page.hasMany(Note); Page.hasMany(Note);
Chapter.hasMany(Note); Chapter.hasMany(Note);
@ -1488,7 +1488,8 @@ describe('relations - integration', function() {
Page.remoteMethod('__throw__errors', {isStatic: false, http: {path: '/throws', verb: 'get'}}); Page.remoteMethod('__throw__errors', {isStatic: false, http: {path: '/throws', verb: 'get'}});
Book.nestRemoting('pages'); // Now `pages` has nestRemoting set to true and no need to call nestRemoting()
// Book.nestRemoting('pages');
Book.nestRemoting('chapters'); Book.nestRemoting('chapters');
Image.nestRemoting('book'); Image.nestRemoting('book');