Created
March 24, 2012 06:20
-
-
Save vidoss/2178987 to your computer and use it in GitHub Desktop.
Using underscore.js while scripting mongodb shell.
This file contains hidden or 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
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. | |
Here are the steps. | |
1) Use underscore to write your db script file (say my_commands.js) | |
E.g: _.each(db.dbname.find().toArray(), function(itm) { ... }) | |
2) Download 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 | |
Thank you so much, this is gold!
Amazing. Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, I was looking for how to do this, this is awesome!