Merge pull request #407 from fabien/fix/apply-props
Supply target to applyProperties function
This commit is contained in:
commit
70833b2a2b
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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 };
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue