Supply target to applyProperties function

This commit is contained in:
Fabien Franzen 2015-01-26 19:09:29 +01:00
parent b2f41f4344
commit a08ef823be
2 changed files with 2 additions and 2 deletions

View File

@ -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];
}

View File

@ -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 };
},