From 14745b13051d7a1788cb156f1466f69b18f90ee9 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Mon, 3 Mar 2014 15:03:05 -0800 Subject: [PATCH] Make the belongsTo relation remotable --- lib/relations.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/relations.js b/lib/relations.js index a5372f92..5b799556 100644 --- a/lib/relations.js +++ b/lib/relations.js @@ -277,6 +277,15 @@ Relation.belongsTo = function (anotherClass, params) { } }; + // Set the remoting metadata so that it can be accessed as /api/// + // 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}; + }; /**