Sticking to style

pull/2/head
Louis Chatriot 9 years ago
parent 8b4e0ecc90
commit 58edd6e407
  1. 14
      lib/model.js
  2. 2
      test/model.test.js

@ -390,16 +390,22 @@ lastStepModifierFunctions.$inc = function (obj, field, value) {
* Updates the value of the field, only if specified field is greater than the current value of the field
*/
lastStepModifierFunctions.$max = function (obj, field, value) {
if (typeof obj[field] === 'undefined') obj[field] = value;
else if (value > obj[field]) obj[field] = value;
if (typeof obj[field] === 'undefined') {
obj[field] = value;
} else if (value > obj[field]) {
obj[field] = value;
}
};
/**
* Updates the value of the field, only if specified field is smaller than the current value of the field
*/
lastStepModifierFunctions.$min = function (obj, field, value) {
if (typeof obj[field] === 'undefined') obj[field] = value;
else if (value < obj[field]) obj[field] = value;
if (typeof obj[field] === 'undefined') { 
obj[field] = value;
} else if (value < obj[field]) {
obj[field] = value;
}
};
// Given its name, create the complete modifier function

@ -732,7 +732,6 @@ describe('Model', function () {
, modified = model.modify(obj, updateQuery);
modified.should.deep.equal({ some: 'thing', number: 12 });
obj.should.deep.equal({ some: 'thing', number: 10 });
});
@ -768,7 +767,6 @@ describe('Model', function () {
, modified = model.modify(obj, updateQuery);
modified.should.deep.equal({ some: 'thing', number: 8 });
obj.should.deep.equal({ some: 'thing', number: 10 });
});

Loading…
Cancel
Save