Merge pull request #407 from fabien/fix/apply-props

Supply target to applyProperties function
This commit is contained in:
Raymond Feng 2015-01-26 11:19:26 -08:00
commit 70833b2a2b
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 };
},