Supply target to applyProperties function
This commit is contained in:
parent
b2f41f4344
commit
a08ef823be
|
@ -213,7 +213,7 @@ RelationDefinition.prototype.applyProperties = function(modelInstance, obj) {
|
||||||
target[this.keyTo] = source[this.keyTo];
|
target[this.keyTo] = source[this.keyTo];
|
||||||
}
|
}
|
||||||
if (typeof this.properties === 'function') {
|
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) {
|
for(var k in data) {
|
||||||
target[k] = data[k];
|
target[k] = data[k];
|
||||||
}
|
}
|
||||||
|
|
|
@ -727,7 +727,7 @@ describe('relations', function () {
|
||||||
Job = db.define('Job', {name: String, type: String});
|
Job = db.define('Job', {name: String, type: String});
|
||||||
|
|
||||||
Category.hasMany(Job, {
|
Category.hasMany(Job, {
|
||||||
properties: function(inst) {
|
properties: function(inst, target) {
|
||||||
if (!inst.jobType) return; // skip
|
if (!inst.jobType) return; // skip
|
||||||
return { type: inst.jobType };
|
return { type: inst.jobType };
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue