From a08ef823bec4b911a6dd9e58c9d167a114575780 Mon Sep 17 00:00:00 2001 From: Fabien Franzen Date: Mon, 26 Jan 2015 19:09:29 +0100 Subject: [PATCH] Supply target to applyProperties function --- lib/relation-definition.js | 2 +- test/relations.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 }; },