Skip to content

Instantly share code, notes, and snippets.

@samyakbhuta
Created February 8, 2014 21:50
Show Gist options
  • Save samyakbhuta/8890850 to your computer and use it in GitHub Desktop.
Save samyakbhuta/8890850 to your computer and use it in GitHub Desktop.
Quick and dirty mongo general purpose command line utility
#!/bin/sh
# Usage : ./mongo-find <db-name> <collection> <attribute> <attribute-value>
mongo $1 --eval \
"
print('Finding ....');
cursor = db.$2.find({'$3':'$4'});
while ( cursor.hasNext() ) {
printjson( cursor.next() );
}
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment