diff --git a/lib/model.js b/lib/model.js index 4a827a64..f3ec47b2 100644 --- a/lib/model.js +++ b/lib/model.js @@ -660,9 +660,24 @@ module.exports = function(registry) { }; - Model.nestRemoting = function(relationName, options, cb) { - if (typeof options === 'function' && !cb) { - cb = options; + /** + * Enabled deeply-nested queries of related models via REST API. + * + * @param {String} relationName Name of the nested relation. + * @options {Object} [options] It is optional. See below. + * @param {String} pathName The HTTP path (relative to the model) at which your remote method is exposed. + * @param {String} filterMethod The filter name. + * @param {String} paramName The argument name that the remote method accepts. + * @param {String} getterName The getter name. + * @param {Boolean} hooks Whether to inherit before/after hooks. + * @callback {Function} filterCallback The Optional filter function. + * @param {Object} SharedMethod object. See [here](https://apidocs.strongloop.com/strong-remoting/#sharedmethod). + * @param {Object} RelationDefinition object which includes relation `type`, `ModelConstructor` of `modelFrom`, `modelTo`, `keyFrom`, `keyTo` and more relation definitions. + */ + + Model.nestRemoting = function(relationName, options, filterCallback) { + if (typeof options === 'function' && !filterCallback) { + filterCallback = options; options = {}; } options = options || {}; @@ -702,7 +717,7 @@ module.exports = function(registry) { // A method should return the method name to use, if it is to be // included as a nested method - a falsy return value will skip. - var filter = cb || options.filterMethod || function(method, relation) { + var filter = filterCallback || options.filterMethod || function(method, relation) { var matches = method.name.match(regExp); if (matches) { return '__' + matches[1] + '__' + relation.name + '__' + matches[2];