lib/patch.js
function scopeRemoting (scopeName, scope, define) {
  var pathName = (scope.options &&
    scope.options.http &&
    scope.options.http.path) ||
    scopeName
  var isStatic = scope.isStatic
  var toModelName = scope.modelTo.modelName

  // https://github.com/strongloop/loopback/issues/811
  // Check if the scope is for a hasMany relation
  var relation = this.relations[scopeName]

  if (relation && relation.modelTo) {
    // For a relation with through model, the toModelName should be the one
    // from the target model
    toModelName = relation.modelTo.modelName
  }

  define('__get__' + scopeName, {
    isStatic: isStatic,
    accessType: 'READ',
    description: 'Queries ' + scopeName + ' of ' + this.modelName + '.',
    http: {
      verb: 'get',
      path: '/' + pathName
    },
    accepts: {
      arg: 'filter',
      type: 'object'
    },
    returns: {
      arg: scopeName,
      type: [toModelName],
      root: true
    }
  })
}
function scopeRemoting (scopeName, scope, define) {
  var pathName = (scope.options &&
    scope.options.http &&
    scope.options.http.path) ||
    scopeName
  var isStatic = scope.isStatic
  var toModelName = scope.modelTo.modelName

  // https://github.com/strongloop/loopback/issues/811
  // Check if the scope is for a hasMany relation
  var relation = this.relations[scopeName]

  if (relation && relation.modelTo) {
    // For a relation with through model, the toModelName should be the one
    // from the target model
    toModelName = relation.modelTo.modelName
  }

  define('__get__' + scopeName, {
    isStatic: isStatic,
    accessType: 'READ',
    description: 'Queries ' + scopeName + ' of ' + this.modelName + '.',
    http: {
      verb: 'get',
      path: '/' + pathName
    },
    accepts: {
      arg: 'filter',
      type: 'object'
    },
    returns: {
      arg: scopeName,
      type: [toModelName],
      root: true
    }
  })
}
function scopeRemoting ( scopeName , scope , define ) { var pathName = ( scope . options && scope . options . http && scope . options . http . path ) || scopeName var isStatic = scope . isStatic var toModelName = scope . modelTo . modelName // https://github.com/strongloop/loopback/issues/811 // Check if the scope is for a hasMany relation var relation = this . relations [ scopeName ] if ( relation && relation . modelTo ) { // For a relation with through model, the toModelName should be the one // from the target model toModelName = relation . modelTo . modelName } define ( '__get__' + scopeName , { isStatic : isStatic , accessType : 'READ' , description : 'Queries ' + scopeName + ' of ' + this . modelName + '.' , http : { verb : 'get' , path : '/' + pathName } , accepts : { arg : 'filter' , type : 'object' } , returns : { arg : scopeName , type : [ toModelName ] , root : true } } ) }
Defines our scope remoting
@public
@memberOf {Patch}
@param {String} scopeName
@param {Object} scope
@param {Function} define
@return {undefined}
Defines our scope remoting