Fix the method for belongsTo with correct receiver
This commit is contained in:
parent
e018efbf43
commit
68d2696248
|
@ -119,9 +119,8 @@ Inclusion.include = function (objects, include, cb) {
|
|||
}
|
||||
}
|
||||
var inst = (obj instanceof self) ? obj : new self(obj);
|
||||
var relationMethod = inst[relationName];
|
||||
// FIXME: [rfeng] How do we pass in the refresh flag?
|
||||
relationMethod(function (err, result) {
|
||||
// Calling the relation method on the instance
|
||||
inst[relationName](function (err, result) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
} else {
|
||||
|
|
|
@ -340,10 +340,13 @@ Relation.belongsTo = function (anotherClass, params) {
|
|||
|
||||
// Define a property for the scope so that we have 'this' for the scoped methods
|
||||
Object.defineProperty(this.prototype, methodName, {
|
||||
enumerable: false,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: function () {
|
||||
var fn = relationMethod.bind(this);
|
||||
var fn = function() {
|
||||
// Call the relation method on the declaring model instance
|
||||
return relationMethod.apply(this, arguments);
|
||||
}
|
||||
// Set the remoting metadata so that it can be accessed as /api/<model>/<id>/<belongsToRelationName>
|
||||
// For example, /api/orders/1/customer
|
||||
fn.shared = true;
|
||||
|
|
Loading…
Reference in New Issue