lib/patch.js
function hasManyRemoting (relationName, relation, define) {
  var pathName = (relation.options.http && relation.options.http.path) ||
    relationName
  var toModelName = relation.modelTo.modelName

  var findHasManyRelationshipsFunc = function (cb) {
    this['__get__' + pathName](cb)
  }

  define(
    '__findRelationships__' + relationName,
    {
      isStatic: false,
      accessType: 'READ',
      description: 'Find relations for ' + relationName + '.',
      http: {
        verb: 'get',
        path: '/relationships/' + pathName
      },
      returns: {
        arg: 'result',
        type: toModelName,
        root: true
      },
      rest: {
        after: convertNullToNotFoundError.bind(null, toModelName)
      }
    },
    findHasManyRelationshipsFunc
  )

  // var createRelationshipFunc = function (cb) {
  // TODO: implement this
  // this is where we need to implement
  // POST /:model/:id/relationships/:relatedModel
  //
  // this['__get__' + pathName](cb)
  // }
  // define('__createRelationships__' + relationName, {
  //   isStatic: false,
  //   accessType: 'READ',
  //   description: 'Create relations for ' + relationName + '.',
  //   http: {
  //     verb: 'post',
  //     path: '/relationships/' + pathName
  //   },
  //   returns: {
  //     arg: 'result',
  //     type: toModelName,
  //     root: true
  //   },
  //   rest: {
  //     after: convertNullToNotFoundError.bind(null, toModelName)
  //   }
  // }, createRelationshipFunc)

  // var updateRelationshipsFunc = function (cb) {
  // TODO: implement this
  // this is where we need to implement
  // PATCH /:model/:id/relationships/:relatedModel
  //
  // this['__get__' + pathName](cb)
  // }
  // define('__updateRelationships__' + relationName, {
  //   isStatic: false,
  //   accessType: 'READ',
  //   description: 'Update relations for ' + relationName + '.',
  //   http: {
  //     verb: 'patch',
  //     path: '/relationships/' + pathName
  //   },
  //   returns: {
  //     arg: 'result',
  //     type: toModelName,
  //     root: true
  //   },
  //   rest: {
  //     after: convertNullToNotFoundError.bind(null, toModelName)
  //   }
  // }, updateRelationshipsFunc)

  // var deleteRelationshipsFunc = function (cb) {
  // TODO: implement this
  // this is where we need to implement
  // DELETE /:model/:id/relationships/:relatedModel
  //
  // this['__get__' + pathName](cb)
  // }
  // define('__deleteRelationships__' + relationName, {
  //   isStatic: false,
  //   accessType: 'READ',
  //   description: 'Delete relations for ' + relationName + '.',
  //   http: {
  //     verb: 'delete',
  //     path: '/relationships/' + pathName
  //   },
  //   returns: {
  //     arg: 'result',
  //     type: toModelName,
  //     root: true
  //   },
  //   rest: {
  //     after: convertNullToNotFoundError.bind(null, toModelName)
  //   }
  // }, deleteRelationshipsFunc)

  if (relation.modelThrough || relation.type === 'referencesMany') {
    var modelThrough = relation.modelThrough || relation.modelTo

    var accepts = []
    if (relation.type === 'hasMany' && relation.modelThrough) {
      // Restrict: only hasManyThrough relation can have additional properties
      accepts.push({
        arg: 'data',
        type: modelThrough.modelName,
        http: {
          source: 'body'
        }
      })
    }
  }
}
function hasManyRemoting (relationName, relation, define) {
  var pathName = (relation.options.http && relation.options.http.path) ||
    relationName
  var toModelName = relation.modelTo.modelName

  var findHasManyRelationshipsFunc = function (cb) {
    this['__get__' + pathName](cb)
  }

  define(
    '__findRelationships__' + relationName,
    {
      isStatic: false,
      accessType: 'READ',
      description: 'Find relations for ' + relationName + '.',
      http: {
        verb: 'get',
        path: '/relationships/' + pathName
      },
      returns: {
        arg: 'result',
        type: toModelName,
        root: true
      },
      rest: {
        after: convertNullToNotFoundError.bind(null, toModelName)
      }
    },
    findHasManyRelationshipsFunc
  )

  // var createRelationshipFunc = function (cb) {
  // TODO: implement this
  // this is where we need to implement
  // POST /:model/:id/relationships/:relatedModel
  //
  // this['__get__' + pathName](cb)
  // }
  // define('__createRelationships__' + relationName, {
  //   isStatic: false,
  //   accessType: 'READ',
  //   description: 'Create relations for ' + relationName + '.',
  //   http: {
  //     verb: 'post',
  //     path: '/relationships/' + pathName
  //   },
  //   returns: {
  //     arg: 'result',
  //     type: toModelName,
  //     root: true
  //   },
  //   rest: {
  //     after: convertNullToNotFoundError.bind(null, toModelName)
  //   }
  // }, createRelationshipFunc)

  // var updateRelationshipsFunc = function (cb) {
  // TODO: implement this
  // this is where we need to implement
  // PATCH /:model/:id/relationships/:relatedModel
  //
  // this['__get__' + pathName](cb)
  // }
  // define('__updateRelationships__' + relationName, {
  //   isStatic: false,
  //   accessType: 'READ',
  //   description: 'Update relations for ' + relationName + '.',
  //   http: {
  //     verb: 'patch',
  //     path: '/relationships/' + pathName
  //   },
  //   returns: {
  //     arg: 'result',
  //     type: toModelName,
  //     root: true
  //   },
  //   rest: {
  //     after: convertNullToNotFoundError.bind(null, toModelName)
  //   }
  // }, updateRelationshipsFunc)

  // var deleteRelationshipsFunc = function (cb) {
  // TODO: implement this
  // this is where we need to implement
  // DELETE /:model/:id/relationships/:relatedModel
  //
  // this['__get__' + pathName](cb)
  // }
  // define('__deleteRelationships__' + relationName, {
  //   isStatic: false,
  //   accessType: 'READ',
  //   description: 'Delete relations for ' + relationName + '.',
  //   http: {
  //     verb: 'delete',
  //     path: '/relationships/' + pathName
  //   },
  //   returns: {
  //     arg: 'result',
  //     type: toModelName,
  //     root: true
  //   },
  //   rest: {
  //     after: convertNullToNotFoundError.bind(null, toModelName)
  //   }
  // }, deleteRelationshipsFunc)

  if (relation.modelThrough || relation.type === 'referencesMany') {
    var modelThrough = relation.modelThrough || relation.modelTo

    var accepts = []
    if (relation.type === 'hasMany' && relation.modelThrough) {
      // Restrict: only hasManyThrough relation can have additional properties
      accepts.push({
        arg: 'data',
        type: modelThrough.modelName,
        http: {
          source: 'body'
        }
      })
    }
  }
}
function hasManyRemoting ( relationName , relation , define ) { var pathName = ( relation . options . http && relation . options . http . path ) || relationName var toModelName = relation . modelTo . modelName var findHasManyRelationshipsFunc = function ( cb ) { this [ '__get__' + pathName ] ( cb ) } define ( '__findRelationships__' + relationName , { isStatic : false , accessType : 'READ' , description : 'Find relations for ' + relationName + '.' , http : { verb : 'get' , path : '/relationships/' + pathName } , returns : { arg : 'result' , type : toModelName , root : true } , rest : { after : convertNullToNotFoundError . bind ( null , toModelName ) } } , findHasManyRelationshipsFunc ) // var createRelationshipFunc = function (cb) { // TODO: implement this // this is where we need to implement // POST /:model/:id/relationships/:relatedModel // // this['__get__' + pathName](cb) // } // define('__createRelationships__' + relationName, { //   isStatic: false, //   accessType: 'READ', //   description: 'Create relations for ' + relationName + '.', //   http: { //     verb: 'post', //     path: '/relationships/' + pathName //   }, //   returns: { //     arg: 'result', //     type: toModelName, //     root: true //   }, //   rest: { //     after: convertNullToNotFoundError.bind(null, toModelName) //   } // }, createRelationshipFunc) // var updateRelationshipsFunc = function (cb) { // TODO: implement this // this is where we need to implement // PATCH /:model/:id/relationships/:relatedModel // // this['__get__' + pathName](cb) // } // define('__updateRelationships__' + relationName, { //   isStatic: false, //   accessType: 'READ', //   description: 'Update relations for ' + relationName + '.', //   http: { //     verb: 'patch', //     path: '/relationships/' + pathName //   }, //   returns: { //     arg: 'result', //     type: toModelName, //     root: true //   }, //   rest: { //     after: convertNullToNotFoundError.bind(null, toModelName) //   } // }, updateRelationshipsFunc) // var deleteRelationshipsFunc = function (cb) { // TODO: implement this // this is where we need to implement // DELETE /:model/:id/relationships/:relatedModel // // this['__get__' + pathName](cb) // } // define('__deleteRelationships__' + relationName, { //   isStatic: false, //   accessType: 'READ', //   description: 'Delete relations for ' + relationName + '.', //   http: { //     verb: 'delete', //     path: '/relationships/' + pathName //   }, //   returns: { //     arg: 'result', //     type: toModelName, //     root: true //   }, //   rest: { //     after: convertNullToNotFoundError.bind(null, toModelName) //   } // }, deleteRelationshipsFunc) if ( relation . modelThrough || relation . type === 'referencesMany' ) { var modelThrough = relation . modelThrough || relation . modelTo var accepts = [ ] if ( relation . type === 'hasMany' && relation . modelThrough ) { // Restrict: only hasManyThrough relation can have additional properties accepts . push ( { arg : 'data' , type : modelThrough . modelName , http : { source : 'body' } } ) } } }
Defines has many remoting.
@public
@memberOf {Patch}
@param {String} relationName
@param {Object} relation
@param {Function} define
@return {undefined}
Defines has many remoting .