Restrict that only hasManyThrough can have additional properties

Signed-off-by: Clark Wang <clark.wangs@gmail.com>
This commit is contained in:
Clark Wang 2014-09-01 13:52:14 +08:00
parent 2452dd1092
commit 0e6bba4ded
1 changed files with 8 additions and 6 deletions

View File

@ -426,17 +426,19 @@ Model.hasManyRemoting = function (relationName, relation, define) {
if (relation.modelThrough || relation.type === 'referencesMany') {
var modelThrough = relation.modelThrough || relation.modelTo;
var accepts = [];
if (relation.type === 'hasMany' && relation.modelThrough) {
accepts.push({arg: 'data', type: modelThrough.modelName, http: {source: 'body'}});
}
var addFunc = this.prototype['__link__' + relationName];
define('__link__' + relationName, {
isStatic: false,
http: {verb: 'put', path: '/' + pathName + '/rel/:fk'},
accepts: [
{arg: 'fk', type: 'any',
accepts: [{arg: 'fk', type: 'any',
description: 'Foreign key for ' + relationName, required: true,
http: {source: 'path'}},
{arg: 'data', type: modelThrough.modelName, http: {source: 'body'}}
],
http: {source: 'path'}}].concat(accepts),
description: 'Add a related item by id for ' + relationName,
returns: {arg: relationName, type: modelThrough.modelName, root: true}
}, addFunc);