Adding back the remoting metadata
This commit is contained in:
parent
046816191d
commit
e2ab9ccc93
|
@ -520,12 +520,30 @@ RelationDefinition.belongsTo = function (modelFrom, modelTo, params) {
|
|||
configurable: true,
|
||||
get: function() {
|
||||
var relation = new BelongsTo(relationDef, this);
|
||||
var relationMethod = relation.related.bind(relation)
|
||||
var relationMethod = relation.related.bind(relation);
|
||||
relationMethod.create = relation.create.bind(relation);
|
||||
relationMethod.build = relation.build.bind(relation);
|
||||
relationMethod._targetClass = relationDef.modelTo.modelName;
|
||||
return relationMethod;
|
||||
}
|
||||
});
|
||||
|
||||
// Wrap the property into a function for remoting
|
||||
// so that it can be accessed as /api/<model>/<id>/<belongsToRelationName>
|
||||
// For example, /api/orders/1/customer
|
||||
var fn = function() {
|
||||
var f = this[relationName];
|
||||
f.apply(this, arguments);
|
||||
};
|
||||
|
||||
fn.shared = true;
|
||||
fn.http = {verb: 'get', path: '/' + relationName};
|
||||
fn.accepts = {arg: 'refresh', type: 'boolean', http: {source: 'query'}};
|
||||
fn.description = 'Fetches belongsTo relation ' + relationName;
|
||||
fn.returns = {arg: relationName, type: 'object', root: true};
|
||||
|
||||
modelFrom.prototype['__get__' + relationName] = fn;
|
||||
|
||||
};
|
||||
|
||||
BelongsTo.prototype.create = function(targetModelData, cb) {
|
||||
|
|
Loading…
Reference in New Issue