MongoDB provides a Javascript shell. But Javascript is no fun without Underscore.js
Turned out its straight forward to use Underscore.js while scripting mongodb.
- Download or clone Underscore.js and run...
% mongo server:27017/dbname underscore.js my_commands.js
OR if you just want undrescore.js in your shell prompt
% mongo server:27017/dbname underscore.js --shell
- Use underscore to write your db script file (say my_commands.js)
_.each(db.dbname.find().toArray(), function(itm) { ... })