Update model.js
*Add doc comments for nestRemoting *change cb to filterCallback in nestRemoting
This commit is contained in:
parent
bfd5059d11
commit
17abd8ac76
23
lib/model.js
23
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];
|
||||
|
|
Loading…
Reference in New Issue