i'm trying use mongodb client "robomongo" http://robomongo.org/
it works fine, can't understand how access functions created on "functions" section...
i want test mapreduce functionality, i've created map() , reduce() function, when write on shell:
db.<name_of_collection>.mapreduce(map, reduce, {out: {inline: 1}});
robomongo give me following error:
referenceerror: map not defined (shell):1
i've tried this:
db.<collection_name>.mapreduce(db.system.js.map, db.system.js.reduce, {out: {inline: 1}});
but again, seems wrong...
uncaught exception: map reduce failed:{ "errmsg" : "exception: javascript execution failed: referenceerror: learn not defined", "code" : 16722, "ok" : 0 }
you can access stored functions in several ways:
1)
db.collection.mapreduce( "function() { return map(); }", "function(key, values) { return reduce(key, values); }", {out: {inline: 1}});
2)
db.collection.mapreduce( function() { return map(); }, function(key, values) { return reduce(key, values); }, {out: {inline: 1}});
note using functions now, not strings in 1)
3)
if using mongodb 2.1 or above, can do:
db.loadserverscripts(); db.collection.mapreduce( map, reduce, {out: {inline: 1}});
more this: http://docs.mongodb.org/manual/tutorial/store-javascript-function-on-server/
robomongo use same engine used mongodb shell. questions mongodb, not robomongo.
Comments
Post a Comment