Restrict that only hasManyThrough can have additional properties
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
This commit is contained in:
parent
2452dd1092
commit
0e6bba4ded
|
@ -427,16 +427,18 @@ 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);
|
||||
|
|
Loading…
Reference in New Issue