Created
March 19, 2013 20:11
-
-
Save travisdahlke/5199641 to your computer and use it in GitHub Desktop.
Mongo 2.4 $add nulls test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use agg_test; | |
test_add = function() { | |
var t = db.things; | |
t.drop(); | |
t.insert({a: 2, b: 3}); | |
var total1 = t.aggregate({$project:{total:{$add:["$a","$b"]}}}).result[0].total; | |
print("a + b = " + total1); | |
var total2 = t.aggregate({$project:{total:{$add:["$a","$b","$c"]}}}).result[0].total; | |
print("a + b + c = " + total2); | |
if (!(total2 == 5)) { | |
print("ERROR: a + b + c should be 5") | |
} | |
} | |
test_add(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment