From 86045d47925f491014e3d9a0487a5e4b72a6ef28 Mon Sep 17 00:00:00 2001 From: Clark Wang Date: Mon, 1 Sep 2014 09:54:55 +0800 Subject: [PATCH] add jsdoc and fix add data to referencesMany.add Signed-off-by: Clark Wang --- lib/relation-definition.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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;