0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
mongodb/jstests/mr_comments.js
2010-11-22 00:53:00 -05:00

29 lines
701 B
JavaScript

t = db.mr_comments
t.drop()
t.insert( { foo : 1 } )
t.insert( { foo : 1 } )
t.insert( { foo : 2 } )
res = db.runCommand(
{ mapreduce : "mr_comments",
map : "// This will fail\n\n // Emit some stuff\n emit(this.foo, 1)\n",
reduce : function(key, values){
return Array.sum(values);
},
out: "mr_comments_out"
});
assert.eq( 3 , res.counts.emit )
res = db.runCommand(
{ mapreduce : "mr_comments",
map : "// This will fail\nfunction(){\n // Emit some stuff\n emit(this.foo, 1)\n}\n",
reduce : function(key, values){
return Array.sum(values);
},
out: "mr_comments_out"
});
assert.eq( 3 , res.counts.emit )