Make the belongsTo relation remotable

This commit is contained in:
Raymond Feng 2014-03-03 15:03:05 -08:00
parent 97c5cfd644
commit 14745b1305
1 changed files with 9 additions and 0 deletions

View File

@ -277,6 +277,15 @@ Relation.belongsTo = function (anotherClass, params) {
}
};
// Set the remoting metadata so that it can be accessed as /api/<model>/<id>/<belongsToRelationName>
// For example, /api/orders/1/customer
var fn = this.prototype[methodName];
fn.shared = true;
fn.http = {verb: 'get', path: '/' + methodName};
fn.accepts = {arg: 'refresh', type: 'boolean', http: {source: 'query'}};
fn.description = 'Fetches belongsTo relation ' + methodName;
fn.returns = {arg: methodName, type: 'object', root: true};
};
/**