From 7e43b94e01bb51f1b060f06eb37972501607903e Mon Sep 17 00:00:00 2001 From: Lukasz Jagodzinski Date: Sun, 18 Oct 2015 20:06:28 +0200 Subject: [PATCH] Fix pushing a value to an array without schema --- lib/modules/fields/pop.js | 4 ++-- lib/modules/fields/pull.js | 6 +++--- lib/modules/fields/push.js | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/modules/fields/pop.js b/lib/modules/fields/pop.js index 23cbe1c..69396e6 100644 --- a/lib/modules/fields/pop.js +++ b/lib/modules/fields/pop.js @@ -143,11 +143,11 @@ proto._popOne = function(fieldName, popValue, options) { Class.emitEvent(event); }; -proto._popMany = function(fieldsValues, options) { +proto._popMany = function(popValues, options) { var doc = this; // Set multiple fields. - _.each(fieldsValues, function(popValue, fieldName) { + _.each(popValues, function(popValue, fieldName) { doc._popOne(fieldName, popValue, options); }); }; diff --git a/lib/modules/fields/pull.js b/lib/modules/fields/pull.js index 873dc3d..0fde81c 100644 --- a/lib/modules/fields/pull.js +++ b/lib/modules/fields/pull.js @@ -96,7 +96,7 @@ proto._pullOne = function(fieldName, pullValue, options) { // Add modifier. if (options.modifier) { if (_.isUndefined(modifierPulledValue)) { - modifierPulledValue = EJSON.clone(fieldValue); + modifierPulledValue = EJSON.clone(pullValue); } if (nestedDoc instanceof Astro.BaseClass) { if (_.isUndefined(index)) { @@ -154,11 +154,11 @@ proto._pullOne = function(fieldName, pullValue, options) { Class.emitEvent(event); }; -proto._pullMany = function(fieldsValues, options) { +proto._pullMany = function(pullValues, options) { var doc = this; // Pull multiple values. - _.each(fieldsValues, function(pullValue, fieldName) { + _.each(pullValues, function(pullValue, fieldName) { doc._pullOne(fieldName, pullValue, options); }); }; diff --git a/lib/modules/fields/push.js b/lib/modules/fields/push.js index 3eed3d6..4c0d45c 100644 --- a/lib/modules/fields/push.js +++ b/lib/modules/fields/push.js @@ -97,7 +97,7 @@ proto._pushOne = function(fieldName, pushValue, options) { // Add modifier. if (options.modifier) { if (_.isUndefined(modifierPushedValue)) { - modifierPushedValue = EJSON.clone(fieldValue); + modifierPushedValue = EJSON.clone(pushValue); } if (nestedDoc instanceof Astro.BaseClass) { if (_.isUndefined(index)) { @@ -153,12 +153,12 @@ proto._pushOne = function(fieldName, pushValue, options) { Class.emitEvent(event); }; -proto._pushMany = function(fieldsValues, options) { +proto._pushMany = function(pushValues, options) { var doc = this; // Set multiple fields. - _.each(fieldsValues, function(fieldValue, fieldName) { - doc._pushOne(fieldName, fieldValue, options); + _.each(pushValues, function(pushValue, fieldName) { + doc._pushOne(fieldName, pushValue, options); }); };