diff --git a/lib/relation-definition.js b/lib/relation-definition.js index 13d1914e..a4d15773 100644 --- a/lib/relation-definition.js +++ b/lib/relation-definition.js @@ -387,36 +387,12 @@ RelationDefinition.hasMany = function hasMany(modelFrom, modelTo, params) { }; var findByIdFunc = scopeMethods.findById; - findByIdFunc.shared = true; - findByIdFunc.http = {verb: 'get', path: '/' + relationName + '/:fk'}; - findByIdFunc.accepts = {arg: 'fk', type: 'any', - description: 'Foreign key for ' + relationName, required: true, - http: {source: 'path'}}; - findByIdFunc.description = 'Find a related item by id for ' + relationName; - findByIdFunc.returns = {arg: 'result', type: 'object', root: true}; - modelFrom.prototype['__findById__' + relationName] = findByIdFunc; var destroyByIdFunc = scopeMethods.destroy; - destroyByIdFunc.shared = true; - destroyByIdFunc.http = {verb: 'delete', path: '/' + relationName + '/:fk'}; - destroyByIdFunc.accepts = {arg: 'fk', type: 'any', - description: 'Foreign key for ' + relationName, required: true, - http: {source: 'path'}}; - destroyByIdFunc.description = 'Delete a related item by id for ' + relationName; - destroyByIdFunc.returns = {}; - modelFrom.prototype['__destroyById__' + relationName] = destroyByIdFunc; var updateByIdFunc = scopeMethods.updateById; - updateByIdFunc.shared = true; - updateByIdFunc.http = {verb: 'put', path: '/' + relationName + '/:fk'}; - updateByIdFunc.accepts = {arg: 'fk', type: 'any', - description: 'Foreign key for ' + relationName, required: true, - http: {source: 'path'}}; - updateByIdFunc.description = 'Update a related item by id for ' + relationName; - updateByIdFunc.returns = {arg: 'result', type: 'object', root: true}; - modelFrom.prototype['__updateById__' + relationName] = updateByIdFunc; if(definition.modelThrough) { @@ -425,42 +401,10 @@ RelationDefinition.hasMany = function hasMany(modelFrom, modelTo, params) { scopeMethods.remove = scopeMethod(definition, 'remove'); var addFunc = scopeMethods.add; - addFunc.shared = true; - addFunc.http = {verb: 'put', path: '/' + relationName + '/rel/:fk'}; - addFunc.accepts = {arg: 'fk', type: 'any', - description: 'Foreign key for ' + relationName, required: true, - http: {source: 'path'}}; - addFunc.description = 'Add a related item by id for ' + relationName; - addFunc.returns = {arg: relationName, type: 'object', root: true}; - modelFrom.prototype['__link__' + relationName] = addFunc; var removeFunc = scopeMethods.remove; - removeFunc.shared = true; - removeFunc.http = {verb: 'delete', path: '/' + relationName + '/rel/:fk'}; - removeFunc.accepts = {arg: 'fk', type: 'any', - description: 'Foreign key for ' + relationName, required: true, - http: {source: 'path'}}; - removeFunc.description = 'Remove the ' + relationName + ' relation to an item by id'; - removeFunc.returns = {}; - modelFrom.prototype['__unlink__' + relationName] = removeFunc; - - // FIXME: [rfeng] How to map a function with callback(err, true|false) to HEAD? - // true --> 200 and false --> 404? - /* - var existsFunc = scopeMethods.exists; - existsFunc.shared = true; - existsFunc.http = {verb: 'head', path: '/' + relationName + '/rel/:fk'}; - existsFunc.accepts = {arg: 'fk', type: 'any', - description: 'Foreign key for ' + relationName, required: true, - http: {source: 'path'}}; - existsFunc.description = 'Check the existence of ' + relationName + ' relation to an item by id'; - existsFunc.returns = {}; - - modelFrom.prototype['__exists__' + relationName] = existsFunc; - */ - } else { scopeMethods.create = scopeMethod(definition, 'create'); scopeMethods.build = scopeMethod(definition, 'build');