summaryrefslogtreecommitdiff
path: root/jstests/core/find_and_modify4.js
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:17:50 -0500
committerJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:18:14 -0500
commit4ae691e8edc87d0e3cfb633bb91c328426be007b (patch)
tree52079a593f54382ca13a2e741633eab1b6271893 /jstests/core/find_and_modify4.js
parenta025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff)
downloadmongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/core/find_and_modify4.js')
-rw-r--r--jstests/core/find_and_modify4.js50
1 files changed, 21 insertions, 29 deletions
diff --git a/jstests/core/find_and_modify4.js b/jstests/core/find_and_modify4.js
index 04abc2f1ce7..b6be565b70a 100644
--- a/jstests/core/find_and_modify4.js
+++ b/jstests/core/find_and_modify4.js
@@ -2,32 +2,31 @@ t = db.find_and_modify4;
t.drop();
// this is the best way to build auto-increment
-function getNextVal(counterName){
+function getNextVal(counterName) {
var ret = t.findAndModify({
- query: {_id: counterName},
- update: {$inc: {val: 1}},
- upsert: true,
- 'new': true,
- });
+ query: {_id: counterName},
+ update: {$inc: {val: 1}},
+ upsert: true, 'new': true,
+ });
return ret;
}
-assert.eq(getNextVal("a"), {_id:"a", val:1});
-assert.eq(getNextVal("a"), {_id:"a", val:2});
-assert.eq(getNextVal("a"), {_id:"a", val:3});
-assert.eq(getNextVal("z"), {_id:"z", val:1});
-assert.eq(getNextVal("z"), {_id:"z", val:2});
-assert.eq(getNextVal("a"), {_id:"a", val:4});
+assert.eq(getNextVal("a"), {_id: "a", val: 1});
+assert.eq(getNextVal("a"), {_id: "a", val: 2});
+assert.eq(getNextVal("a"), {_id: "a", val: 3});
+assert.eq(getNextVal("z"), {_id: "z", val: 1});
+assert.eq(getNextVal("z"), {_id: "z", val: 2});
+assert.eq(getNextVal("a"), {_id: "a", val: 4});
t.drop();
-function helper(upsert){
+function helper(upsert) {
return t.findAndModify({
- query: {_id: "asdf"},
- update: {$inc: {val: 1}},
- upsert: upsert,
- 'new': false // the default
- });
+ query: {_id: "asdf"},
+ update: {$inc: {val: 1}},
+ upsert: upsert,
+ 'new': false // the default
+ });
}
// upsert:false so nothing there before and after
@@ -37,19 +36,12 @@ assert.eq(t.count(), 0);
// upsert:true so nothing there before; something there after
assert.eq(helper(true), null);
assert.eq(t.count(), 1);
-assert.eq(helper(true), {_id: 'asdf', val: 1});
-assert.eq(helper(false), {_id: 'asdf', val: 2}); // upsert only matters when obj doesn't exist
-assert.eq(helper(true), {_id: 'asdf', val: 3});
-
+assert.eq(helper(true), {_id: 'asdf', val: 1});
+assert.eq(helper(false), {_id: 'asdf', val: 2}); // upsert only matters when obj doesn't exist
+assert.eq(helper(true), {_id: 'asdf', val: 3});
// _id created if not specified
-var out = t.findAndModify({
- query: {a:1},
- update: {$set: {b: 2}},
- upsert: true,
- 'new': true
- });
+var out = t.findAndModify({query: {a: 1}, update: {$set: {b: 2}}, upsert: true, 'new': true});
assert.neq(out._id, undefined);
assert.eq(out.a, 1);
assert.eq(out.b, 2);
-