diff --git a/lib/model.js b/lib/model.js index a3edb4a1..f9a9173b 100644 --- a/lib/model.js +++ b/lib/model.js @@ -286,6 +286,11 @@ module.exports = function(registry) { relation.type === 'referencesMany') { 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 diff --git a/test/relations.integration.js b/test/relations.integration.js index 8b70fc20..3000a395 100644 --- a/test/relations.integration.js +++ b/test/relations.integration.js @@ -1475,7 +1475,7 @@ describe('relations - integration', function() { ); app.model(Chapter, {dataSource: 'db'}); - Book.hasMany(Page); + Book.hasMany(Page, {options: {nestRemoting: true}}); Book.hasMany(Chapter); Page.hasMany(Note); Chapter.hasMany(Note); @@ -1488,7 +1488,8 @@ describe('relations - integration', function() { 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'); Image.nestRemoting('book');