diff options
author | clang-format-7.0.1 <adam.martin@10gen.com> | 2019-07-26 18:42:24 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-07-26 18:42:24 -0400 |
commit | c1a45ebbb0530e3d0201321d725527f1eb83ffce (patch) | |
tree | f523079dc5ded3052eefbdcaae424b7502df5b25 /jstests/core/update_min_max_examples.js | |
parent | c9599d8610c3da0b7c3da65667aff821063cf5b9 (diff) | |
download | mongo-c1a45ebbb0530e3d0201321d725527f1eb83ffce.tar.gz |
Apply formatting per `clang-format-7.0.1`
Diffstat (limited to 'jstests/core/update_min_max_examples.js')
-rw-r--r-- | jstests/core/update_min_max_examples.js | 121 |
1 files changed, 62 insertions, 59 deletions
diff --git a/jstests/core/update_min_max_examples.js b/jstests/core/update_min_max_examples.js index 62e870147bf..3ec86705a1f 100644 --- a/jstests/core/update_min_max_examples.js +++ b/jstests/core/update_min_max_examples.js @@ -1,71 +1,74 @@ // Basic examples for $min/$max (function() { - "use strict"; +"use strict"; - let res; - const coll = db.update_min_max; - coll.drop(); +let res; +const coll = db.update_min_max; +coll.drop(); - // $min for number - coll.insert({_id: 1, a: 2}); - res = coll.update({_id: 1}, {$min: {a: 1}}); - assert.writeOK(res); - assert.eq(coll.findOne({_id: 1}).a, 1); +// $min for number +coll.insert({_id: 1, a: 2}); +res = coll.update({_id: 1}, {$min: {a: 1}}); +assert.writeOK(res); +assert.eq(coll.findOne({_id: 1}).a, 1); - // $max for number - coll.insert({_id: 2, a: 2}); - res = coll.update({_id: 2}, {$max: {a: 1}}); - assert.writeOK(res); - assert.eq(coll.findOne({_id: 2}).a, 2); +// $max for number +coll.insert({_id: 2, a: 2}); +res = coll.update({_id: 2}, {$max: {a: 1}}); +assert.writeOK(res); +assert.eq(coll.findOne({_id: 2}).a, 2); - // $min for Date - let date = new Date(); - coll.insert({_id: 3, a: date}); - // setMilliseconds() will roll over to change seconds if necessary. - date.setMilliseconds(date.getMilliseconds() + 2); - // Test that we have advanced the date and it's no longer the same as the one we inserted. - assert.eq(null, coll.findOne({_id: 3, a: date})); - const origDoc = coll.findOne({_id: 3}); - assert.commandWorked(coll.update({_id: 3}, {$min: {a: date}})); - assert.eq(coll.findOne({_id: 3}).a, origDoc.a); +// $min for Date +let date = new Date(); +coll.insert({_id: 3, a: date}); +// setMilliseconds() will roll over to change seconds if necessary. +date.setMilliseconds(date.getMilliseconds() + 2); +// Test that we have advanced the date and it's no longer the same as the one we inserted. +assert.eq(null, coll.findOne({_id: 3, a: date})); +const origDoc = coll.findOne({_id: 3}); +assert.commandWorked(coll.update({_id: 3}, {$min: {a: date}})); +assert.eq(coll.findOne({_id: 3}).a, origDoc.a); - // $max for Date - coll.insert({_id: 4, a: date}); - // setMilliseconds() will roll over to change seconds if necessary. - date.setMilliseconds(date.getMilliseconds() + 2); - // Test that we have advanced the date and it's no longer the same as the one we inserted. - assert.eq(null, coll.findOne({_id: 4, a: date})); - res = coll.update({_id: 4}, {$max: {a: date}}); - assert.writeOK(res); - assert.eq(coll.findOne({_id: 4}).a, date); +// $max for Date +coll.insert({_id: 4, a: date}); +// setMilliseconds() will roll over to change seconds if necessary. +date.setMilliseconds(date.getMilliseconds() + 2); +// Test that we have advanced the date and it's no longer the same as the one we inserted. +assert.eq(null, coll.findOne({_id: 4, a: date})); +res = coll.update({_id: 4}, {$max: {a: date}}); +assert.writeOK(res); +assert.eq(coll.findOne({_id: 4}).a, date); - // $max for small number - coll.insert({_id: 5, a: 1e-15}); - // Slightly bigger than 1e-15. - const biggerval = 0.000000000000001000000000000001; - res = coll.update({_id: 5}, {$max: {a: biggerval}}); - assert.writeOK(res); - assert.eq(coll.findOne({_id: 5}).a, biggerval); +// $max for small number +coll.insert({_id: 5, a: 1e-15}); +// Slightly bigger than 1e-15. +const biggerval = 0.000000000000001000000000000001; +res = coll.update({_id: 5}, {$max: {a: biggerval}}); +assert.writeOK(res); +assert.eq(coll.findOne({_id: 5}).a, biggerval); - // $min for a small number - coll.insert({_id: 6, a: biggerval}); - res = coll.update({_id: 6}, {$min: {a: 1e-15}}); - assert.writeOK(res); - assert.eq(coll.findOne({_id: 6}).a, 1e-15); +// $min for a small number +coll.insert({_id: 6, a: biggerval}); +res = coll.update({_id: 6}, {$min: {a: 1e-15}}); +assert.writeOK(res); +assert.eq(coll.findOne({_id: 6}).a, 1e-15); - // $max with positional operator - let insertdoc = {_id: 7, y: [{a: 2}, {a: 6}, {a: [9, 1, 1]}]}; - coll.insert(insertdoc); - res = coll.update({_id: 7, "y.a": 6}, {$max: {"y.$.a": 7}}); - assert.writeOK(res); - insertdoc.y[1].a = 7; - assert.docEq(coll.findOne({_id: 7}), insertdoc); +// $max with positional operator +let insertdoc = {_id: 7, y: [{a: 2}, {a: 6}, {a: [9, 1, 1]}]}; +coll.insert(insertdoc); +res = coll.update({_id: 7, "y.a": 6}, {$max: {"y.$.a": 7}}); +assert.writeOK(res); +insertdoc.y[1].a = 7; +assert.docEq(coll.findOne({_id: 7}), insertdoc); - // $min with positional operator - insertdoc = {_id: 8, y: [{a: 2}, {a: 6}, {a: [9, 1, 1]}]}; - coll.insert(insertdoc); - res = coll.update({_id: 8, "y.a": 6}, {$min: {"y.$.a": 5}}); - assert.writeOK(res); - insertdoc.y[1].a = 5; - assert.docEq(coll.findOne({_id: 8}), insertdoc); +// $min with positional operator +insertdoc = { + _id: 8, + y: [{a: 2}, {a: 6}, {a: [9, 1, 1]}] +}; +coll.insert(insertdoc); +res = coll.update({_id: 8, "y.a": 6}, {$min: {"y.$.a": 5}}); +assert.writeOK(res); +insertdoc.y[1].a = 5; +assert.docEq(coll.findOne({_id: 8}), insertdoc); }()); |