summaryrefslogtreecommitdiff
path: root/jstests/update_mul_examples.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/update_mul_examples.js')
-rw-r--r--jstests/update_mul_examples.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/jstests/update_mul_examples.js b/jstests/update_mul_examples.js
new file mode 100644
index 00000000000..a57fa0a3380
--- /dev/null
+++ b/jstests/update_mul_examples.js
@@ -0,0 +1,24 @@
+// Basic examples for $mul (multiply)
+var coll = db.update_mul;
+coll.drop();
+
+// $mul positive
+coll.remove({})
+coll.save({_id:1, a:2});
+coll.update({}, {$mul: {a: 10}})
+assert.gleSuccess(coll.getDB())
+assert.eq(coll.findOne().a, 20)
+
+// $mul negative
+coll.remove({})
+coll.save({_id:1, a:2});
+coll.update({}, {$mul: {a: -10}})
+assert.gleSuccess(coll.getDB())
+assert.eq(coll.findOne().a, -20)
+
+// $mul zero
+coll.remove({})
+coll.save({_id:1, a:2});
+coll.update({}, {$mul: {a: 0}})
+assert.gleSuccess(coll.getDB())
+assert.eq(coll.findOne().a, 0)