diff --git a/lib/relation-definition.js b/lib/relation-definition.js index aae43be1..cc314f1a 100644 --- a/lib/relation-definition.js +++ b/lib/relation-definition.js @@ -213,7 +213,7 @@ RelationDefinition.prototype.applyProperties = function(modelInstance, obj) { target[this.keyTo] = source[this.keyTo]; } if (typeof this.properties === 'function') { - var data = this.properties.call(this, source); + var data = this.properties.call(this, source, target); for(var k in data) { target[k] = data[k]; } diff --git a/test/relations.test.js b/test/relations.test.js index 8acc391a..8318e73b 100644 --- a/test/relations.test.js +++ b/test/relations.test.js @@ -727,7 +727,7 @@ describe('relations', function () { Job = db.define('Job', {name: String, type: String}); Category.hasMany(Job, { - properties: function(inst) { + properties: function(inst, target) { if (!inst.jobType) return; // skip return { type: inst.jobType }; },