From be38cb3a6f1bdb0888b14a43454f5e2f34ca8f4a Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Mon, 18 May 2015 09:34:25 -0700 Subject: [PATCH] Fix comments --- lib/relation-definition.js | 82 +++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/lib/relation-definition.js b/lib/relation-definition.js index fc369bce..918af0b2 100644 --- a/lib/relation-definition.js +++ b/lib/relation-definition.js @@ -1417,7 +1417,7 @@ BelongsTo.prototype.related = function (condOrRefresh, options, cb) { cb = condOrRefresh; condOrRefresh = false; } else if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // order.customer(condOrRefresh, cb) cb = options; options = {}; } @@ -1518,7 +1518,7 @@ BelongsTo.prototype.related = function (condOrRefresh, options, cb) { */ BelongsTo.prototype.getAsync = function (options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // order.customer.getAsync(cb) cb = options; options = {}; } @@ -1684,7 +1684,7 @@ RelationDefinition.hasOne = function (modelFrom, modelTo, params) { */ HasOne.prototype.create = function (targetModelData, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.profile.create(options, cb) cb = options; options = {}; } @@ -1727,7 +1727,7 @@ HasOne.prototype.create = function (targetModelData, options, cb) { HasOne.prototype.update = function(targetModelData, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.profile.update(data, cb) cb = options; options = {}; } @@ -1748,7 +1748,7 @@ HasOne.prototype.update = function(targetModelData, options, cb) { HasOne.prototype.destroy = function (options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.profile.destroy(cb) cb = options; options = {}; } @@ -1773,7 +1773,7 @@ HasOne.prototype.destroy = function (options, cb) { */ HasMany.prototype.create = function (targetModelData, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.orders.create(data, cb) cb = options; options = {}; } @@ -1861,11 +1861,11 @@ HasOne.prototype.related = function (condOrRefresh, options, cb) { condOrRefresh = false; } else if (typeof condOrRefresh === 'function' && options === undefined && cb === undefined) { - // order.customer(cb) + // customer.profile(cb) cb = condOrRefresh; condOrRefresh = false; } else if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.profile(condOrRefresh, cb) cb = options; options = {}; } @@ -1925,7 +1925,7 @@ HasOne.prototype.related = function (condOrRefresh, options, cb) { HasOne.prototype.getAsync = function (options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // order.profile.getAsync(cb) cb = options; options = {}; } @@ -2054,7 +2054,7 @@ EmbedsOne.prototype.related = function (condOrRefresh, options, cb) { cb = condOrRefresh; condOrRefresh = false; } else if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // order.customer(condOrRefresh, cb) cb = options; options = {}; } @@ -2089,7 +2089,7 @@ EmbedsOne.prototype.embeddedValue = function(modelInstance) { EmbedsOne.prototype.create = function (targetModelData, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // order.customer.create(data, cb) cb = options; options = {}; } @@ -2170,7 +2170,7 @@ EmbedsOne.prototype.build = function (targetModelData) { EmbedsOne.prototype.update = function (targetModelData, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // order.customer.update(data, cb) cb = options; options = {}; } @@ -2200,7 +2200,7 @@ EmbedsOne.prototype.update = function (targetModelData, options, cb) { EmbedsOne.prototype.destroy = function (options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // order.customer.destroy(cb) cb = options; options = {}; } @@ -2424,10 +2424,11 @@ EmbedsMany.prototype.related = function(receiver, scopeParams, condOrRefresh, op if (typeof condOrRefresh === 'function' && options === undefined && cb === undefined) { + // customer.emails(receiver, scopeParams, cb) cb = condOrRefresh; condOrRefresh = false; } else if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.emails(receiver, scopeParams, condOrRefresh, cb) cb = options; options = {}; } @@ -2460,7 +2461,7 @@ EmbedsMany.prototype.related = function(receiver, scopeParams, condOrRefresh, op EmbedsMany.prototype.findById = function (fkId, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // order.emails(fkId, cb) cb = options; options = {}; } @@ -2492,7 +2493,7 @@ EmbedsMany.prototype.findById = function (fkId, options, cb) { EmbedsMany.prototype.exists = function (fkId, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.emails.exists(fkId, cb) cb = options; options = {}; } @@ -2505,11 +2506,12 @@ EmbedsMany.prototype.exists = function (fkId, options, cb) { EmbedsMany.prototype.updateById = function (fkId, data, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.emails.updateById(fkId, data, cb) cb = options; options = {}; } if (typeof data === 'function') { + // customer.emails.updateById(fkId, cb) cb = data; data = {}; } @@ -2549,7 +2551,7 @@ EmbedsMany.prototype.updateById = function (fkId, data, options, cb) { EmbedsMany.prototype.destroyById = function (fkId, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.emails.destroyById(fkId, cb) cb = options; options = {}; } @@ -2579,11 +2581,15 @@ EmbedsMany.prototype.destroyById = function (fkId, options, cb) { EmbedsMany.prototype.destroyAll = function(where, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.emails.destroyAll(where, cb); cb = options; options = {}; + } else if (typeof where === 'function' && + options === undefined && cb === undefined) { + // customer.emails.destroyAll(cb); + cb = where; + where = {}; } - if (typeof where === 'function') cb = where, where = {}; var propertyName = this.definition.keyFrom; var modelInstance = this.modelInstance; @@ -2636,7 +2642,7 @@ EmbedsMany.prototype.create = function (targetModelData, options, cb) { var modelInstance = this.modelInstance; if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.emails.create(cb) cb = options; options = {}; } @@ -2737,11 +2743,12 @@ EmbedsMany.prototype.build = function(targetModelData) { */ EmbedsMany.prototype.add = function (acInst, data, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.emails.add(acInst, data, cb) cb = options; options = {}; - } - if (typeof data === 'function') { + } else if (typeof data === 'function' && + options === undefined && cb === undefined) { + // customer.emails.add(acInst, cb) cb = data; data = {}; } @@ -2790,7 +2797,7 @@ EmbedsMany.prototype.add = function (acInst, data, options, cb) { */ EmbedsMany.prototype.remove = function (acInst, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.emails.remove(acInst, cb) cb = options; options = {}; } @@ -2934,11 +2941,11 @@ ReferencesMany.prototype.related = function(receiver, scopeParams, condOrRefresh if (typeof condOrRefresh === 'function' && options === undefined && cb === undefined) { - // order.customer(cb) + // customer.orders(receiver, scopeParams, cb) cb = condOrRefresh; condOrRefresh = undefined; } else if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.orders(receiver, scopeParams, condOrRefresh, cb) cb = options; options = {}; if (typeof condOrRefresh === 'boolean') { @@ -2960,7 +2967,7 @@ ReferencesMany.prototype.related = function(receiver, scopeParams, condOrRefresh ReferencesMany.prototype.findById = function (fkId, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.orders.findById(fkId, cb) cb = options; options = {}; } @@ -3015,7 +3022,7 @@ ReferencesMany.prototype.findById = function (fkId, options, cb) { ReferencesMany.prototype.exists = function (fkId, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.orders.exists(fkId, cb) cb = options; options = {}; } @@ -3031,11 +3038,12 @@ ReferencesMany.prototype.exists = function (fkId, options, cb) { ReferencesMany.prototype.updateById = function (fkId, data, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.orders.updateById(fkId, data, cb) cb = options; options = {}; - } - if (typeof data === 'function') { + } else if (typeof data === 'function' && + options === undefined && cb === undefined) { + // customer.orders.updateById(fkId, cb) cb = data; data = {}; } @@ -3050,7 +3058,7 @@ ReferencesMany.prototype.updateById = function (fkId, data, options, cb) { ReferencesMany.prototype.destroyById = function (fkId, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.orders.destroyById(fkId, cb) cb = options; options = {}; } @@ -3067,7 +3075,7 @@ ReferencesMany.prototype.destroyById = function (fkId, options, cb) { ReferencesMany.prototype.at = function (index, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.orders.at(index, cb) cb = options; options = {}; } @@ -3080,7 +3088,7 @@ ReferencesMany.prototype.at = function (index, options, cb) { ReferencesMany.prototype.create = function (targetModelData, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.orders.create(data, cb) cb = options; options = {}; } @@ -3141,7 +3149,7 @@ ReferencesMany.prototype.build = function(targetModelData) { */ ReferencesMany.prototype.add = function (acInst, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.orders.add(acInst, cb) cb = options; options = {}; } @@ -3197,7 +3205,7 @@ ReferencesMany.prototype.add = function (acInst, options, cb) { */ ReferencesMany.prototype.remove = function (acInst, options, cb) { if (typeof options === 'function' && cb === undefined) { - // order.customer(options, cb) + // customer.orders.remove(acInst, cb) cb = options; options = {}; }