Fix remoting types for related models
This commit is contained in:
parent
405d04f4ad
commit
ab8d82d7f9
|
@ -136,7 +136,8 @@ Model.setup = function () {
|
||||||
|
|
||||||
var idDesc = ModelCtor.modelName + ' id';
|
var idDesc = ModelCtor.modelName + ' id';
|
||||||
ModelCtor.sharedCtor.accepts = [
|
ModelCtor.sharedCtor.accepts = [
|
||||||
{arg: 'id', type: 'any', http: {source: 'path'}, description: idDesc}
|
{arg: 'id', type: 'any', required: true, http: {source: 'path'},
|
||||||
|
description: idDesc}
|
||||||
// {arg: 'instance', type: 'object', http: {source: 'body'}}
|
// {arg: 'instance', type: 'object', http: {source: 'body'}}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -347,6 +348,7 @@ Model.belongsToRemoting = function(relationName, relation, define) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Model.hasManyRemoting = function (relationName, relation, define) {
|
Model.hasManyRemoting = function (relationName, relation, define) {
|
||||||
|
var toModelName = relation.modelTo.modelName;
|
||||||
var findByIdFunc = this.prototype['__findById__' + relationName];
|
var findByIdFunc = this.prototype['__findById__' + relationName];
|
||||||
define('__findById__' + relationName, {
|
define('__findById__' + relationName, {
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
|
@ -355,7 +357,7 @@ Model.hasManyRemoting = function (relationName, relation, define) {
|
||||||
description: 'Foreign key for ' + relationName, required: true,
|
description: 'Foreign key for ' + relationName, required: true,
|
||||||
http: {source: 'path'}},
|
http: {source: 'path'}},
|
||||||
description: 'Find a related item by id for ' + relationName,
|
description: 'Find a related item by id for ' + relationName,
|
||||||
returns: {arg: 'result', type: relation.modelTo.modelName, root: true}
|
returns: {arg: 'result', type: toModelName, root: true}
|
||||||
}, findByIdFunc);
|
}, findByIdFunc);
|
||||||
|
|
||||||
var destroyByIdFunc = this.prototype['__destroyById__' + relationName];
|
var destroyByIdFunc = this.prototype['__destroyById__' + relationName];
|
||||||
|
@ -373,11 +375,14 @@ Model.hasManyRemoting = function (relationName, relation, define) {
|
||||||
define('__updateById__' + relationName, {
|
define('__updateById__' + relationName, {
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
http: {verb: 'put', path: '/' + relationName + '/:fk'},
|
http: {verb: 'put', path: '/' + relationName + '/:fk'},
|
||||||
accepts: {arg: 'fk', type: 'any',
|
accepts: [
|
||||||
|
{arg: 'fk', type: 'any',
|
||||||
description: 'Foreign key for ' + relationName, required: true,
|
description: 'Foreign key for ' + relationName, required: true,
|
||||||
http: {source: 'path'}},
|
http: {source: 'path'}},
|
||||||
|
{arg: 'data', type: toModelName, http: {source: 'body'}}
|
||||||
|
],
|
||||||
description: 'Update a related item by id for ' + relationName,
|
description: 'Update a related item by id for ' + relationName,
|
||||||
returns: {arg: 'result', type: relation.modelTo.modelName, root: true}
|
returns: {arg: 'result', type: toModelName, root: true}
|
||||||
}, updateByIdFunc);
|
}, updateByIdFunc);
|
||||||
|
|
||||||
if (relation.modelThrough) {
|
if (relation.modelThrough) {
|
||||||
|
@ -432,7 +437,7 @@ Model.scopeRemoting = function(relationName, relation, define) {
|
||||||
define('__create__' + relationName, {
|
define('__create__' + relationName, {
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
http: {verb: 'post', path: '/' + relationName},
|
http: {verb: 'post', path: '/' + relationName},
|
||||||
accepts: {arg: 'data', type: 'object', http: {source: 'body'}},
|
accepts: {arg: 'data', type: toModelName, http: {source: 'body'}},
|
||||||
description: 'Creates a new instance in ' + relationName + ' of this model.',
|
description: 'Creates a new instance in ' + relationName + ' of this model.',
|
||||||
returns: {arg: 'data', type: toModelName, root: true}
|
returns: {arg: 'data', type: toModelName, root: true}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue