diff --git a/lib/relation-definition.js b/lib/relation-definition.js index 220b18a8..50320f6b 100644 --- a/lib/relation-definition.js +++ b/lib/relation-definition.js @@ -918,6 +918,7 @@ HasManyThrough.prototype.create = function create(data, done) { /** * Add the target model instance to the 'hasMany' relation * @param {Object|ID} acInst The actual instance or id value + * @param {Object} [data] Optional data object for the through model to be created */ HasManyThrough.prototype.add = function (acInst, data, done) { var self = this; @@ -2553,12 +2554,17 @@ ReferencesMany.prototype.build = function(targetModelData) { * Add the target model instance to the 'embedsMany' relation * @param {Object|ID} acInst The actual instance or id value */ -ReferencesMany.prototype.add = function (acInst, cb) { +ReferencesMany.prototype.add = function (acInst, data, cb) { var self = this; var definition = this.definition; var modelTo = this.definition.modelTo; var modelInstance = this.modelInstance; + if (typeof data === 'function') { + cb = data; + data = {}; + } + var pk = this.definition.keyTo; var fk = this.definition.keyFrom;